xale-db 1.0
minimal SQL engine, written in c++
Loading...
Searching...
No Matches
Xale::Net::TcpClient Class Reference

#include <TcpClient.h>

Collaboration diagram for Xale::Net::TcpClient:
Collaboration graph

Public Member Functions

 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.

Constructor & Destructor Documentation

◆ TcpClient()

Xale::Net::TcpClient::TcpClient ( std::unique_ptr< Xale::Net::ISocketFactory > socketFactory)

◆ ~TcpClient()

Xale::Net::TcpClient::~TcpClient ( )

Member Function Documentation

◆ 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
ipThe IP address of the server to connect to.
portThe 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
bufferA pointer to a string where the received data will be stored.
sizeThe 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]

int Xale::Net::TcpClient::receive ( Xale::Net::Packet * buffer,
size_t size )

Receives a packet from the connected TCP server.

Parameters
bufferA pointer to the packet where the received data will be stored.
sizeThe 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
dataA pointer to the data to be sent.
sizeThe 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]

int Xale::Net::TcpClient::send ( const Xale::Net::Packet * data,
size_t size )

Sends a packet to the connected TCP server.

Parameters
dataA pointer to the packet to be sent.
sizeThe 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: