Public Types | |
| typedef std::vector< char > | Bytes |
Public Member Functions | |
| TcpClient (const std::string &hostname, int port, int timeoutInMillisecons=0) | |
| Initializes a new instance of the TcpClient class and connects to the specified port on the specified host. | |
| TcpClient () | |
| Initializes a new instance of the TcpClient class. | |
| ~TcpClient (void) | |
| Destructor. | |
| void | connect (const std::string &hostname, int port, int timeoutInMillisecons=0) |
| Connects to the specified port on the specified host. | |
| void | close () |
| Closes the TCP connection. | |
| void | setNoDelay (bool setTcpNoDelayOption=true) |
| Sets a value that disables a delay when send or receive buffers are not full. | |
| bool | getNoDelay () const |
| Gets a value that disables a delay when send or receive buffers are not full. | |
| void | send (const std::string &value) |
| Sends the given value. | |
| void | send (const char *buffer, size_t bufferLength) |
| Sends the given value. | |
| const Bytes & | receive (int timeoutInMillisecons=0) |
| const Bytes & | receive (size_t numberOfBytesToReceive, int timeoutInMillisecons=0) |
| Receives exactly the given number of bytes. | |
Definition at line 20 of file TcpClient.h.
| typedef std::vector<char> Bytes |
Definition at line 69 of file TcpClient.h.
| TcpClient | ( | const std::string & | hostname, | |
| int | port, | |||
| int | timeoutInMillisecons = 0 | |||
| ) |
Initializes a new instance of the TcpClient class and connects to the specified port on the specified host.
| hostname | The DNS name of the remote host to which you intend to connect (or its IP address). | |
| port | The port number of the remote host to which you intend to connect. | |
| timeoutInMillisecons | Timeout value in milliseconds. If 0 then the method blocks until some data is received. |
| ~TcpClient | ( | void | ) |
Destructor.
| void connect | ( | const std::string & | hostname, | |
| int | port, | |||
| int | timeoutInMillisecons = 0 | |||
| ) |
Connects to the specified port on the specified host.
| hostname | The DNS name of the remote host to which you intend to connect (or its IP address). | |
| port | The port number of the remote host to which you intend to connect. | |
| timeoutInMillisecons | Timeout value in milliseconds. If 0 then the method blocks until some data is received. |
| void close | ( | ) |
Closes the TCP connection.
| void setNoDelay | ( | bool | setTcpNoDelayOption = true |
) |
Sets a value that disables a delay when send or receive buffers are not full.
When setTcpNoDelayOption is false, a TcpClient does not send a packet over the network until it has collected a significant amount of outgoing data. Because of the amount of overhead in a TCP segment, sending small amounts of data is inefficient. However, situations do exist where you need to send very small amounts of data or expect immediate responses from each packet you send. Your decision should weigh the relative importance of network efficiency versus application requirements.
| bool getNoDelay | ( | ) | const |
Gets a value that disables a delay when send or receive buffers are not full.
| void send | ( | const std::string & | value | ) |
Sends the given value.
| void send | ( | const char * | buffer, | |
| size_t | bufferLength | |||
| ) |
Sends the given value.
| const Bytes& receive | ( | int | timeoutInMillisecons = 0 |
) |
| const Bytes& receive | ( | size_t | numberOfBytesToReceive, | |
| int | timeoutInMillisecons = 0 | |||
| ) |
Receives exactly the given number of bytes.
| numberOfBytesToReceive | Number of bytes to received. | |
| timeoutInMillisecons | Timeout value in milliseconds. If 0 then the method blocks until all bytes are received. |
1.5.2