Files
MARTe-Integrated-Components/Source/Components/Interfaces/TCPStreamService/TCPSConn.h
T
Martino FerrariandClaude Opus 4.6 50d85363a3 feat(tcp): TCPStreamer DataSources, in-process TCPStreamService, stream multiplexing and TCPStreamJoin
Add TCPStreamer/TCPStreamerClient (TCP transport behind the UDPSServerI/UDPSClientI
seam), an optional single in-process TCPStreamService serving many streams over
worker threads, multiplexed SUBSCRIBE (comma list, stream index in fragmentIdx),
and TCPStreamJoin, which merges several streams into one sample-and-hold stream
paced by a master. StreamHub takes a comma list of streams over one connection.
Includes GTests, E2E scenarios s58-s73 and docs.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-11-06 13:41:27 +01:00

71 lines
1.8 KiB
C++

#ifndef TCPS_CONN_H_
#define TCPS_CONN_H_
/**
* @file TCPSConn.h
* @brief One accepted connection of a TCPStreamService (internal).
*
* Ownership: created by the acceptor thread, then owned and deleted by exactly
* one TCPSWorker. `streams` and `closeRequested` are the only fields touched
* from other threads; `stream` is guarded by the service topology lock, the
* queue by `qMutex`.
*/
#include "CompilerTypes.h"
#include "FastPollingMutexSem.h"
#include "TCPSFrameQueue.h"
#include "TCPStreamService.h"
#include "UDPSProtocol.h"
#include <unistd.h>
namespace MARTe {
class TCPSWorker;
class TCPSServiceStream;
struct TCPSConn {
TCPSConn(int socketFd, TCPSWorker *owner, uint32 queueDepth, uint64 handshakeDeadline)
: fd(socketFd), worker(owner), subscribed(false), hsHave(0u),
hsWant(UDPS_HEADER_SIZE), hsHeaderOk(false), hsDeadline(handshakeDeadline),
numStreams(0u), closeRequested(false) {
for (uint32 i = 0u; i < TCPS_MAX_CONN_STREAMS; i++) {
streams[i] = NULL_PTR(TCPSServiceStream *);
}
q.Init(queueDepth);
}
~TCPSConn() {
if (fd >= 0) {
(void)close(fd);
}
}
int fd;
TCPSWorker *worker;
/* Worker-thread only. */
bool subscribed;
uint8 hs[UDPS_HEADER_SIZE + TCPS_MAX_SUBSCRIBE_PAYLOAD + 1u];
uint32 hsHave;
uint32 hsWant;
bool hsHeaderOk;
uint64 hsDeadline;
/* Service topology lock. */
TCPSServiceStream *streams[TCPS_MAX_CONN_STREAMS]; ///< index = stream index on the wire
uint32 numStreams;
volatile bool closeRequested;
/* qMutex. */
FastPollingMutexSem qMutex;
TCPSFrameQueue q;
private:
TCPSConn(const TCPSConn &);
TCPSConn &operator=(const TCPSConn &);
};
} // namespace MARTe
#endif // TCPS_CONN_H_