Conscience Core
Classes | Public Member Functions | List of all members
conscience_core::communication::TcpClient Class Reference

#include <TcpClient.h>

Classes

struct  ExistingSocket
 

Public Member Functions

 TcpClient (const string &ipAddress, unsigned int port)
 
 TcpClient (const ExistingSocket &existingSocket, bool releaseAsioContext=false)
 
 ~TcpClient ()
 
string getIpAddress () const
 
unsigned int getPort () const
 
optional< vector< unsigned char > * > send (const vector< unsigned char > *bytes, bool noResponse=false, bool close=false)
 
optional< vector< unsigned char > * > receive ()
 
void release ()
 
bool isReleased () const
 
optional< unsigned int > getTimeout () const
 
void setTimeout (unsigned timeoutSeconds)
 
void scheduleCloseAfterTimeout ()
 
void cancelCloseAfterTimeout ()
 

Constructor & Destructor Documentation

◆ TcpClient() [1/2]

conscience_core::communication::TcpClient::TcpClient ( const string &  ipAddress,
unsigned int  port 
)

Connects TCP client and throws error if failure

◆ TcpClient() [2/2]

conscience_core::communication::TcpClient::TcpClient ( const ExistingSocket existingSocket,
bool  releaseAsioContext = false 
)

Creates a wrapping TcpClient over an existing socket (for instance when server accepts a remote connection, a TcpClient will be created on resulting socket to send and receive data)

Parameters
releaseAsioContextif true, tcp client, on destroy, will stop and delete asioContext

◆ ~TcpClient()

conscience_core::communication::TcpClient::~TcpClient ( )

Member Function Documentation

◆ cancelCloseAfterTimeout()

void conscience_core::communication::TcpClient::cancelCloseAfterTimeout ( )

◆ getIpAddress()

string conscience_core::communication::TcpClient::getIpAddress ( ) const

◆ getPort()

unsigned int conscience_core::communication::TcpClient::getPort ( ) const

◆ getTimeout()

optional< unsigned int > conscience_core::communication::TcpClient::getTimeout ( ) const
Returns
timeout in seconds, if any

◆ isReleased()

bool conscience_core::communication::TcpClient::isReleased ( ) const

◆ receive()

optional< vector< unsigned char > * > conscience_core::communication::TcpClient::receive ( )

◆ release()

void conscience_core::communication::TcpClient::release ( )

◆ scheduleCloseAfterTimeout()

void conscience_core::communication::TcpClient::scheduleCloseAfterTimeout ( )

will close soket after getTimeout() seconds

◆ send()

optional< vector< unsigned char > * > conscience_core::communication::TcpClient::send ( const vector< unsigned char > *  bytes,
bool  noResponse = false,
bool  close = false 
)
Parameters
byteswill be deleted in this method

◆ setTimeout()

void conscience_core::communication::TcpClient::setTimeout ( unsigned  timeoutSeconds)

throws error if failure

Parameters
timeoutSecondsin sconds

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