DelegateMQ
Loading...
Searching...
No Matches
TcpTransport Class Reference

Linux TCP transport implementation for DelegateMQ. More...

#include <LinuxTcpTransport.h>

Inheritance diagram for TcpTransport:
ITransport ITransport

Public Types

enum class  Type { SERVER , CLIENT , SERVER , CLIENT }
 
enum class  Type { SERVER , CLIENT , SERVER , CLIENT }
 

Public Member Functions

 TcpTransport ()
 
 ~TcpTransport ()
 
int Create (Type type, const char *addr, uint16_t port)
 
void Close ()
 
virtual int Send (xostringstream &os, const DmqHeader &header) override
 
virtual int Receive (xstringstream &is, DmqHeader &header) override
 
void SetTransportMonitor (ITransportMonitor *tm)
 
void SetSendTransport (ITransport *st)
 
void SetRecvTransport (ITransport *rt)
 
 TcpTransport ()
 
 ~TcpTransport ()
 
int Create (Type type, LPCSTR addr, USHORT port)
 
void Close ()
 
virtual int Send (xostringstream &os, const DmqHeader &header) override
 
virtual int Receive (xstringstream &is, DmqHeader &header) override
 
void SetTransportMonitor (ITransportMonitor *tm)
 
void SetSendTransport (ITransport *st)
 
void SetRecvTransport (ITransport *rt)
 
- Public Member Functions inherited from ITransport

Detailed Description

Linux TCP transport implementation for DelegateMQ.

See also
https://github.com/endurodave/DelegateMQ David Lafreniere, 2025.

This class implements the ITransport interface using standard Linux BSD sockets. It supports both CLIENT and SERVER modes for reliable, stream-based communication.

Key Features:

  1. Thread-Safe I/O: Executes socket operations directly on the calling thread, relying on OS-level thread safety for concurrent Send/Receive operations.
  2. Low Latency: Configures TCP_NODELAY to disable Nagle's algorithm, optimized    for the small, frequent packets typical of RPC/delegate calls.
  3. Non-Blocking Poll: Utilizes select() with a 1-second timeout in the receive    loop to allow for cooperative multitasking and clean shutdowns without busy waiting.
  4. Reliability: Fully integrated with TransportMonitor to handle sequence    tracking and ACK generation.
Note
This class is specific to Linux and uses POSIX socket APIs.

Member Enumeration Documentation

◆ Type [1/2]

enum class TcpTransport::Type
strong
Enumerator
SERVER 
CLIENT 
SERVER 
CLIENT 

◆ Type [2/2]

enum class TcpTransport::Type
strong
Enumerator
SERVER 
CLIENT 
SERVER 
CLIENT 

Constructor & Destructor Documentation

◆ TcpTransport() [1/2]

TcpTransport::TcpTransport ( )
inline

◆ ~TcpTransport() [1/2]

TcpTransport::~TcpTransport ( )
inline

◆ TcpTransport() [2/2]

TcpTransport::TcpTransport ( )
inline

◆ ~TcpTransport() [2/2]

TcpTransport::~TcpTransport ( )
inline

Member Function Documentation

◆ Close() [1/2]

void TcpTransport::Close ( )
inline

◆ Close() [2/2]

void TcpTransport::Close ( )
inline

◆ Create() [1/2]

int TcpTransport::Create ( Type type,
const char * addr,
uint16_t port )
inline

◆ Create() [2/2]

int TcpTransport::Create ( Type type,
LPCSTR addr,
USHORT port )
inline

◆ Receive() [1/2]

virtual int TcpTransport::Receive ( xstringstream & is,
DmqHeader & header )
inlineoverridevirtual

Receive data from a remote

Parameters
[out]isThe received incoming data bytes, not including the header.
[out]headerIncoming delegate message header.
Returns
0 if success.

Implements ITransport.

◆ Receive() [2/2]

virtual int TcpTransport::Receive ( xstringstream & is,
DmqHeader & header )
inlineoverridevirtual

Receive data from a remote

Parameters
[out]isThe received incoming data bytes, not including the header.
[out]headerIncoming delegate message header.
Returns
0 if success.

Implements ITransport.

◆ Send() [1/2]

virtual int TcpTransport::Send ( xostringstream & os,
const DmqHeader & header )
inlineoverridevirtual

Send data to a remote

Parameters
[in]osOutput stream to send.
[in]headerThe header to send.
Returns
0 if success.

Implements ITransport.

◆ Send() [2/2]

virtual int TcpTransport::Send ( xostringstream & os,
const DmqHeader & header )
inlineoverridevirtual

Send data to a remote

Parameters
[in]osOutput stream to send.
[in]headerThe header to send.
Returns
0 if success.

Implements ITransport.

◆ SetRecvTransport() [1/2]

void TcpTransport::SetRecvTransport ( ITransport * rt)
inline

◆ SetRecvTransport() [2/2]

void TcpTransport::SetRecvTransport ( ITransport * rt)
inline

◆ SetSendTransport() [1/2]

void TcpTransport::SetSendTransport ( ITransport * st)
inline

◆ SetSendTransport() [2/2]

void TcpTransport::SetSendTransport ( ITransport * st)
inline

◆ SetTransportMonitor() [1/2]

void TcpTransport::SetTransportMonitor ( ITransportMonitor * tm)
inline

◆ SetTransportMonitor() [2/2]

void TcpTransport::SetTransportMonitor ( ITransportMonitor * tm)
inline

The documentation for this class was generated from the following files: