#include <TcpClient.h>
|
| | TcpClient (std::unique_ptr< Xale::Net::ISocketFactory > socketFactory) |
| | ~TcpClient () |
| bool | connect (const std::string &ip, int port) |
| | Connects to a TCP server at the specified IP address and port.
|
| int | send (const std::string *data, size_t size) |
| | Sends data to the connected TCP server.
|
| int | receive (std::string *buffer, size_t size) |
| | Receives data from the connected TCP server.
|
| int | send (const Xale::Net::Packet *data, size_t size) |
| | Sends a packet to the connected TCP server.
|
| int | receive (Xale::Net::Packet *buffer, size_t size) |
| | Receives a packet from the connected TCP server.
|
| void | close () |
| | Closes the connection to the TCP server.
|
◆ TcpClient()
◆ ~TcpClient()
| Xale::Net::TcpClient::~TcpClient |
( |
| ) |
|
◆ close()
| void Xale::Net::TcpClient::close |
( |
| ) |
|
Closes the connection to the TCP server.
◆ connect()
| bool Xale::Net::TcpClient::connect |
( |
const std::string & | ip, |
|
|
int | port ) |
Connects to a TCP server at the specified IP address and port.
- Parameters
-
| ip | The IP address of the server to connect to. |
| port | The port number of the server to connect to. |
- Returns
- True if the connection was successful, false otherwise.
◆ receive() [1/2]
| int Xale::Net::TcpClient::receive |
( |
std::string * | buffer, |
|
|
size_t | size ) |
Receives data from the connected TCP server.
- Parameters
-
| buffer | A pointer to a string where the received data will be stored. |
| size | The maximum size of the data to be received in bytes. |
- Returns
- The number of bytes received, or -1 if an error occurred.
- Deprecated
- Use receive(Xale::Net::Packet* buffer, size_t size) instead for better packet handling.
◆ receive() [2/2]
Receives a packet from the connected TCP server.
- Parameters
-
| buffer | A pointer to the packet where the received data will be stored. |
| size | The maximum size of the packet to be received in bytes. |
- Returns
- The number of bytes received, or -1 if an error occurred.
◆ send() [1/2]
| int Xale::Net::TcpClient::send |
( |
const std::string * | data, |
|
|
size_t | size ) |
Sends data to the connected TCP server.
- Parameters
-
| data | A pointer to the data to be sent. |
| size | The size of the data to be sent in bytes. |
- Returns
- The number of bytes sent, or -1 if an error occurred.
- Deprecated
- Use send(const Xale::Net::Packet* data, size_t size) instead for better packet handling.
◆ send() [2/2]
Sends a packet to the connected TCP server.
- Parameters
-
| data | A pointer to the packet to be sent. |
| size | The size of the packet to be sent in bytes. |
- Returns
- The number of bytes sent, or -1 if an error occurred.
The documentation for this class was generated from the following files: