DAVID4 SDK
1.8.7
|
Implementation of a TCP client. More...
#include <TcpClient.h>
Public Member Functions | |
TcpClient (const std::string &serverAddress, uint16_t serverPort) | |
Constructor. More... | |
virtual | ~TcpClient () |
Destructor. | |
bool | Connect () |
Connect to the remote machine. More... | |
void | Close () |
Close socket. | |
std::string | GetServerAddress () const |
Get remote IP address. More... | |
uint16_t | GetServerPort () const |
Get remote port. More... | |
int64_t | ReceiveString (std::string &data) |
Receive data from the network. More... | |
bool | ReceiveBinary (void *data, size_t numBytes) |
Receive binary data from the network. More... | |
int64_t | SendString (const std::string &data) |
Send data. More... | |
bool | SendBinary (const void *data, size_t numBytes) |
Send binary data to network. More... | |
Implementation of a TCP client.
Definition at line 38 of file TcpClient.h.
david::TcpClient::TcpClient | ( | const std::string & | serverAddress, |
uint16_t | serverPort | ||
) |
Constructor.
[in] | serverAddress | Remote IP address. Use 127.0.0.1 for localhost. |
[in] | serverPort | Remote port. |
bool david::TcpClient::Connect | ( | ) |
Connect to the remote machine.
True if successful, false otherwise.
std::string david::TcpClient::GetServerAddress | ( | ) | const |
Get remote IP address.
uint16_t david::TcpClient::GetServerPort | ( | ) | const |
Get remote port.
bool david::TcpClient::ReceiveBinary | ( | void * | data, |
size_t | numBytes | ||
) |
Receive binary data from the network.
[out] | data | Destination buffer with size of at least 'numBytes'. |
[in] | numBytes | Number of bytes to be received. |
int64_t david::TcpClient::ReceiveString | ( | std::string & | data) |
Receive data from the network.
Function blocks until data is received.
[out] | data | Gets the received data. |
bool david::TcpClient::SendBinary | ( | const void * | data, |
size_t | numBytes | ||
) |
Send binary data to network.
[in] | data | Source buffer with size of at least 'numBytes'. |
[in] | numBytes | Number of bytes to be send. |
int64_t david::TcpClient::SendString | ( | const std::string & | data) |
Send data.
[in] | data | Data to be sent. |