Class TcpInterface
Defined in File tcp_interface.hpp
Inheritance Relationships
Base Type
public network_bridge::NetworkInterface
(Class NetworkInterface)
Class Documentation
-
class TcpInterface : public network_bridge::NetworkInterface
Represents a TCP network interface.
The TcpInterface class is a concrete implementation of the NetworkInterface abstract class. It provides functionality for opening, closing, receiving and writing data to a TCP interface. It also handles receiving data asynchronously and provides error handling capabilities.
Public Functions
-
inline TcpInterface()
-
inline virtual ~TcpInterface()
-
virtual void open() override
Opens the network connection.
This method should be implemented by derived classes to establish the network connection. Should handle all network setup, including sockets, starting threads, etc
-
virtual void close() override
Closes the network connection.
This method should be implemented by derived classes to close the network connection. Cleanly stop threads, close sockets, etc.
-
virtual void write(const std::vector<uint8_t> &data) override
Writes data to the network.
This method should be implemented by derived classes to send data over the network.
- Parameters:
data – The data to be written.
Protected Functions
-
virtual void initialize_() override
Initializes interface by loading parameters.
Called from NetworkInterface::initialize()
-
void load_parameters()
-
void setup_server()
-
void setup_client()
-
void start_receive()
-
void receive(size_t payload_size)
-
void error_handler(const boost::system::error_code &ec, const std::string &error_message, bool fatal = false)
Handles errors from the UDP interface.
- Parameters:
ec – The error code from the operation.
error_message – The error message to log.
fatal – Whether the error is fatal.
-
inline TcpInterface()