NDEVR
API Documentation
AdaptiveTCPClient

TCP client that implements the NDEVR communication protocol over a QTcpSocket. More...

Public Member Functions

 AdaptiveTCPClient (QObject *parent=nullptr)
 Constructs the TCP client.
void * connectTo (const NDEVRServerInfo &server) override
 Establishes a connection to the specified server.
void connectToServer (const StringView &host, uint04 port)
 Initiates a TCP connection to the specified host and port.
virtual void disconnectFrom (void *socket) override
 Disconnects from the specified socket.
virtual bool isOpen (void *socket=nullptr) const override
 Checks whether the socket is currently connected.
virtual uint08 rx (void *socket, NDEVRDataPacket &packet) override
 Receives data from the socket into a packet.
virtual uint08 tx (void *socket, NDEVRDataPacket &packet, uint08 size) override
 Transmits packet data through the socket.
virtual void wait (const TimeSpan &span, LogPtr log=nullptr) override
 Waits for the specified time span, processing events.

Protected Attributes

QTimer m_send_timer
 Timer for periodic send buffer flushing.
QTcpSocket * m_server_socket
 The underlying TCP socket.
QTimer reconnectTimer
 Timer for automatic reconnection attempts.

Detailed Description

TCP client that implements the NDEVR communication protocol over a QTcpSocket.

Provides automatic reconnection, buffered sending, and integrates with the NDEVRCommunicationLogic framework for packet-based data transfer.

Definition at line 15 of file AdaptiveTCPClient.h.

Constructor & Destructor Documentation

◆ AdaptiveTCPClient()

AdaptiveTCPClient::AdaptiveTCPClient ( QObject * parent = nullptr)
explicit

Constructs the TCP client.

Parameters
[in]parentOptional parent QObject.

Member Function Documentation

◆ connectTo()

void * AdaptiveTCPClient::connectTo ( const NDEVRServerInfo & server)
override

Establishes a connection to the specified server.

Parameters
[in]serverThe server information to connect to.
Returns
An opaque pointer to the connection socket.

◆ connectToServer()

void AdaptiveTCPClient::connectToServer ( const StringView & host,
uint04 port )

Initiates a TCP connection to the specified host and port.

Parameters
[in]hostThe hostname or IP address to connect to.
[in]portThe TCP port number.

◆ disconnectFrom()

virtual void AdaptiveTCPClient::disconnectFrom ( void * socket)
overridevirtual

Disconnects from the specified socket.

Parameters
[in]socketThe socket to disconnect.

◆ isOpen()

virtual bool AdaptiveTCPClient::isOpen ( void * socket = nullptr) const
overridevirtual

Checks whether the socket is currently connected.

Parameters
[in]socketThe socket to check, or nullptr for the default.
Returns
True if the connection is open.

◆ rx()

virtual uint08 AdaptiveTCPClient::rx ( void * socket,
NDEVRDataPacket & packet )
overridevirtual

Receives data from the socket into a packet.

Parameters
[in]socketThe socket to receive from.
[in]packetThe packet buffer to fill.
Returns
The number of bytes received.

◆ tx()

virtual uint08 AdaptiveTCPClient::tx ( void * socket,
NDEVRDataPacket & packet,
uint08 size )
overridevirtual

Transmits packet data through the socket.

Parameters
[in]socketThe socket to send through.
[in]packetThe packet data to send.
[in]sizeThe number of bytes to send.
Returns
The number of bytes sent.

◆ wait()

virtual void AdaptiveTCPClient::wait ( const TimeSpan & span,
LogPtr log = nullptr )
overridevirtual

Waits for the specified time span, processing events.

Parameters
[in]spanThe duration to wait.
[in]logOptional log for progress reporting.

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