#include <icy/turn/client/tcpclient.h>Inherits:
Client
TCP transport TURN client with relay connection management per RFC 6062. Uses a single TCP control connection for STUN signalling and opens additional TCP relay connections for each peer via the Connect / ConnectionBind flow.
| Return | Name | Description |
|---|---|---|
TCPClient | #### Parameters | |
void | start virtual | Connects the socket to the TURN server and starts the allocation sequence. Permissions must be added via addPermission() before calling this. |
void | stop virtual | Stops the control connection, cancels all relay connections, and calls the base class stop(). |
void | sendConnectRequest virtual | Sends a Connect request to the server asking it to open a TCP connection to peerAddress on the client's behalf (RFC 6062 section 4.3). |
void | sendData virtual | Sends raw data to peerAddress over the established relay connection. The peer must have an active permission and a bound relay connection. |
bool | handleResponse virtual | Extends the base handler with Connect, ConnectionBind, and ConnectionAttempt responses. |
void | handleConnectResponse virtual | Processes a successful Connect response; extracts the connection ID and calls createAndBindConnection(). |
void | handleConnectErrorResponse virtual | Processes a Connect error response; notifies the observer that binding failed. |
void | handleConnectionBindResponse virtual | Processes a successful ConnectionBind response; arms the relay socket for data transfer and notifies the observer. |
void | handleConnectionBindErrorResponse virtual | Processes a ConnectionBind error response; frees the failed connection. |
void | handleConnectionAttemptIndication virtual | Processes a ConnectionAttempt indication from the server; optionally accepts the incoming peer connection by calling createAndBindConnection(). |
bool | createAndBindConnection virtual | Opens a new TCP relay socket to the TURN server and sends a ConnectionBind request carrying connectionID. |
bool | onRelayConnectionConnect virtual | Relay socket connect callback; sends the ConnectionBind request. |
bool | onRelayDataReceived virtual | Relay socket receive callback; forwards data to the observer. |
bool | onRelayConnectionError virtual | Relay socket error callback; notifies the observer of the error. |
bool | onRelayConnectionClosed virtual | Relay socket close callback; notifies the observer and frees the connection. |
void | freeConnection | Removes the relay connection for peerAddress, unregisters its callbacks, and deletes the associated RelayConnectionBinding. |
int | transportProtocol virtual | #### Returns |
ConnectionManager & | connections | #### Returns |
const char * | className virtual const inline |
TCPClient(TCPClientObserver & observer, const Client::Options & options)observer Observer for TCP-specific relay events.
options Client configuration; defaults to loopback server, 5-min lifetime.
virtual
virtual void start()Connects the socket to the TURN server and starts the allocation sequence. Permissions must be added via addPermission() before calling this.
virtual
virtual void stop()Stops the control connection, cancels all relay connections, and calls the base class stop().
virtual
virtual void sendConnectRequest(const net::Address & peerAddress)Sends a Connect request to the server asking it to open a TCP connection to peerAddress on the client's behalf (RFC 6062 section 4.3).
peerAddress Target peer address.virtual
virtual void sendData(const char * data, size_t size, const net::Address & peerAddress)Sends raw data to peerAddress over the established relay connection. The peer must have an active permission and a bound relay connection.
data Payload bytes.
size Number of bytes to send.
peerAddress Destination peer (must have an entry in connections()).
virtual
virtual bool handleResponse(const stun::Message & response)Extends the base handler with Connect, ConnectionBind, and ConnectionAttempt responses.
response Incoming STUN response.true if the message was handled.
virtual
virtual void handleConnectResponse(const stun::Message & response)Processes a successful Connect response; extracts the connection ID and calls createAndBindConnection().
response Connect success response.virtual
virtual void handleConnectErrorResponse(const stun::Message & response)Processes a Connect error response; notifies the observer that binding failed.
response Connect error response.virtual
virtual void handleConnectionBindResponse(const stun::Message & response)Processes a successful ConnectionBind response; arms the relay socket for data transfer and notifies the observer.
response ConnectionBind success response.virtual
virtual void handleConnectionBindErrorResponse(const stun::Message & response)Processes a ConnectionBind error response; frees the failed connection.
response ConnectionBind error response.virtual
virtual void handleConnectionAttemptIndication(const stun::Message & response)Processes a ConnectionAttempt indication from the server; optionally accepts the incoming peer connection by calling createAndBindConnection().
response ConnectionAttempt indication message.virtual
virtual bool createAndBindConnection(uint32_t connectionID, const net::Address & peerAddress)Opens a new TCP relay socket to the TURN server and sends a ConnectionBind request carrying connectionID.
connectionID TURN CONNECTION-ID from the server.
peerAddress Peer associated with this connection.
true on success.
virtual
virtual bool onRelayConnectionConnect(net::Socket & socket)Relay socket connect callback; sends the ConnectionBind request.
socket The relay socket that just connected.virtual
virtual bool onRelayDataReceived(net::Socket & socket, const MutableBuffer & buffer, const net::Address & peerAddress)Relay socket receive callback; forwards data to the observer.
socket The receiving relay socket.
buffer Received data.
peerAddress Source address (populated by the socket layer).
virtual
virtual bool onRelayConnectionError(net::Socket & socket, const Error & error)Relay socket error callback; notifies the observer of the error.
socket The affected relay socket.
error Error descriptor.
virtual
virtual bool onRelayConnectionClosed(net::Socket & socket)Relay socket close callback; notifies the observer and frees the connection.
socket The closed relay socket.void freeConnection(const net::Address & peerAddress)Removes the relay connection for peerAddress, unregisters its callbacks, and deletes the associated RelayConnectionBinding.
peerAddress Peer whose connection to release.virtual
virtual int transportProtocol()kProtocolTCP (6).
ConnectionManager & connections()Reference to the map of active relay connections keyed by peer address.
virtual const inline
virtual inline const char * className() const| Return | Name | Description |
|---|---|---|
TCPClientObserver & | _observer | |
ConnectionManager | _connections |
TCPClientObserver & _observerConnectionManager _connections