TCP Server Class that allows to create a server to interact with send and receive operations.

#include <tcpServer.h>

Public Member Functions

void startAccept ()
 The begging of the accept.
 
 TcpAsyncServer (boost::asio::io_context &io_context, std::string ip, unsigned short port)
 TCP Asynchronous server constructor. More...
 
virtual ~TcpAsyncServer ()
 TCP Asynchronous server destructor.
 
void close (boost::system::error_code &rEc)
 Close the Asynchronous TCP server. More...
 
void stopAll ()
 Close all connections.
 
void publishMsg (const std::string &message)
 Publish a message to all clients. More...
 
void setWriteStatusHandler (boost::function< void(const boost::system::error_code &error, std::size_t size)> writeStatusHandler)
 Bridge to write connection function. More...
 
void setReceiveSendHandler (boost::function< void(const boost::system::error_code &error, const char *receiveData, std::string &sendData)> receiveSendHandler)
 Bridge to write connection function. More...
 

Constructor & Destructor Documentation

TcpAsyncServer ( boost::asio::io_context &  io_context,
std::string  ip,
unsigned short  port 
)
Parameters
io_contextIO Context
ipThe destination IP.
portWhich port.

Member Function Documentation

void close ( boost::system::error_code &  rEc)
Parameters
rEcerror code
void publishMsg ( const std::string &  message)
Parameters
messageMessage to be sent
void setReceiveSendHandler ( boost::function< void(const boost::system::error_code &error, const char *receiveData, std::string &sendData)>  receiveSendHandler)
Parameters
receiveSendHandlerThe read handler to send data.
void setWriteStatusHandler ( boost::function< void(const boost::system::error_code &error, std::size_t size)>  writeStatusHandler)
Parameters
writeStatusHandlerThe write handler to call when finish.