Mania++
 All Classes Functions Variables Pages
TcpClient.h
1 #ifndef SOCKET_H_
2 #define SOCKET_H_
3 
4 #include <iostream> //cout
5 #include <stdio.h> //printf
6 #include <string.h> //strlen
7 #include <string> //string
8 #include <sstream>
9 #include <vector>
10 #include <unistd.h>
11 #include <sys/socket.h> //socket
12 #include <arpa/inet.h> //inet_addr
13 #include <netdb.h> //hostent
14 
15 #include "../Utils/Hex.h"
16 
17 //* TcpClient
25 class TcpClient
26 {
27 public:
31  TcpClient();
32 
41  bool Connect(std::string address, int port);
42 
50  bool Send(std::string data);
51 
57  std::string Receive(int size);
58 
64  bool SearchForCallBacks(int timeout);
65 
69  void Close();
70 
73 private:
74  int sock;
75  std::string address;
76  int port;
77  struct sockaddr_in server;
78 };
79 
80 #endif // SOCKET_H_
std::string address
Address of the server.
Definition: TcpClient.h:75
bool Send(std::string data)
Sends an XML message to the server.
Definition: TcpClient.cpp:77
void Close()
Closes the socket with the server.
Definition: TcpClient.cpp:12
int sock
Socket connection with the server.
Definition: TcpClient.h:74
Socket connection with server.
Definition: TcpClient.h:25
long RequestHandle
Current request identifier.
Definition: TcpClient.h:71
std::string Receive(int size)
Returns data received from the server.
Definition: TcpClient.cpp:112
bool Connect(std::string address, int port)
Creates a socket connection with the server.
Definition: TcpClient.cpp:22
bool SearchForCallBacks(int timeout)
Wait (timeout) for callbacks from the server.
Definition: TcpClient.cpp:136
struct sockaddr_in server
Server/socket information.
Definition: TcpClient.h:77
int port
XML-RPC port of the server.
Definition: TcpClient.h:76
TcpClient()
Initializes variables.
Definition: TcpClient.cpp:3