Class astutedds::rtps::TCPConnection
ClassList > astutedds > rtps > TCPConnection
Represents a single TCP connection.
#include <tcp_transport.hpp>
Classes
| Type | Name |
|---|---|
| struct | Stats Get connection statistics. |
Public Functions
| Type | Name |
|---|---|
| TCPConnection (TCPConnectionMode mode) Create TCP connection. |
|
| TCPConnection (const TCPConnection &) = delete |
|
| void | adopt_socket (platform::socket_t socket_fd, const std::string & remote_addr, uint16_t remote_port) Adopt existing socket (SERVER mode) |
| void | close () Close connection. |
| bool | connect (const std::string & address, uint16_t port, std::chrono::milliseconds timeout=std::chrono::seconds(5)) Connect to remote endpoint (CLIENT mode) |
| Stats | get_stats () const |
| bool | is_connected () const Check if connected. |
| uint16_t | local_port () const Get local port. |
| TCPConnection & | operator= (const TCPConnection &) = delete |
| void | process_io () Process I/O (called from transport thread) |
| Locator_t | remote_locator () const Get remote locator. |
| bool | send (const std::vector< uint8_t > & data) Send RTPS message. |
| void | set_receive_callback (TCPReceiveCallback callback) Set receive callback. |
| void | set_state_callback (TCPStateCallback callback) Set state change callback. |
| platform::socket_t | socket_fd () const Get socket file descriptor. |
| TCPConnectionState | state () const Get connection state. |
| ~TCPConnection () |
Public Functions Documentation
function TCPConnection [1/2]
Create TCP connection.
explicit astutedds::rtps::TCPConnection::TCPConnection (
TCPConnectionMode mode
)
Parameters:
modeCLIENT or SERVER
function TCPConnection [2/2]
astutedds::rtps::TCPConnection::TCPConnection (
const TCPConnection &
) = delete
function adopt_socket
Adopt existing socket (SERVER mode)
void astutedds::rtps::TCPConnection::adopt_socket (
platform::socket_t socket_fd,
const std::string & remote_addr,
uint16_t remote_port
)
Parameters:
socket_fdAccepted socket file descriptorremote_addrRemote addressremote_portRemote port
function close
Close connection.
void astutedds::rtps::TCPConnection::close ()
function connect
Connect to remote endpoint (CLIENT mode)
bool astutedds::rtps::TCPConnection::connect (
const std::string & address,
uint16_t port,
std::chrono::milliseconds timeout=std::chrono::seconds(5)
)
Parameters:
addressIP addressportPort numbertimeoutConnection timeout
Returns:
true if connection initiated
function get_stats
Stats astutedds::rtps::TCPConnection::get_stats () const
function is_connected
Check if connected.
inline bool astutedds::rtps::TCPConnection::is_connected () const
function local_port
Get local port.
inline uint16_t astutedds::rtps::TCPConnection::local_port () const
function operator=
TCPConnection & astutedds::rtps::TCPConnection::operator= (
const TCPConnection &
) = delete
function process_io
Process I/O (called from transport thread)
void astutedds::rtps::TCPConnection::process_io ()
function remote_locator
Get remote locator.
Locator_t astutedds::rtps::TCPConnection::remote_locator () const
function send
Send RTPS message.
bool astutedds::rtps::TCPConnection::send (
const std::vector< uint8_t > & data
)
Parameters:
dataMessage data
Returns:
true if queued successfully
function set_receive_callback
Set receive callback.
void astutedds::rtps::TCPConnection::set_receive_callback (
TCPReceiveCallback callback
)
function set_state_callback
Set state change callback.
void astutedds::rtps::TCPConnection::set_state_callback (
TCPStateCallback callback
)
function socket_fd
Get socket file descriptor.
inline platform::socket_t astutedds::rtps::TCPConnection::socket_fd () const
function state
Get connection state.
inline TCPConnectionState astutedds::rtps::TCPConnection::state () const
function ~TCPConnection
astutedds::rtps::TCPConnection::~TCPConnection ()
The documentation for this class was generated from the following file include/astutedds/rtps/tcp_transport.hpp