xale-db 1.0
minimal SQL engine, written in c++
Loading...
Searching...
No Matches
TcpClient.h
Go to the documentation of this file.
1#ifndef NET_TCP_CLIENT_H
2#define NET_TCP_CLIENT_H
3
5#include "Net/Packet/Packet.h"
6
7#include <string>
8#include <memory>
9
10namespace Xale::Net
11{
13 {
14 public:
15 TcpClient(std::unique_ptr<Xale::Net::ISocketFactory> socketFactory);
16 ~TcpClient();
17
24 bool connect(const std::string& ip, int port);
25
33 int send(const std::string* data, size_t size);
34
42 int receive(std::string* buffer, size_t size);
43
50 int send(const Xale::Net::Packet* data, size_t size);
51
58 int receive(Xale::Net::Packet* buffer, size_t size);
59
63 void close();
64 private:
65 std::unique_ptr<Xale::Net::ISocket> _socket;
66 std::unique_ptr<Xale::Net::ISocketFactory> _socketFactory;
67
68 };
69}
70
71#endif // NET_TCP_CLIENT_H
Represents a network packet for communication in Xale DB.
Definition Packet.h:15
~TcpClient()
Definition TcpClient.cpp:10
int receive(std::string *buffer, size_t size)
Receives data from the connected TCP server.
Definition TcpClient.cpp:34
TcpClient(std::unique_ptr< Xale::Net::ISocketFactory > socketFactory)
Definition TcpClient.cpp:5
bool connect(const std::string &ip, int port)
Connects to a TCP server at the specified IP address and port.
Definition TcpClient.cpp:15
void close()
Closes the connection to the TCP server.
Definition TcpClient.cpp:64
int send(const std::string *data, size_t size)
Sends data to the connected TCP server.
Definition TcpClient.cpp:26
Definition IPacket.h:8