Mania++
 All Classes Functions Variables Pages
Public Member Functions | Public Attributes | Private Attributes | List of all members
TcpClient Class Reference

Socket connection with server. More...

#include <TcpClient.h>

Public Member Functions

 TcpClient ()
 Initializes variables.
 
bool Connect (std::string address, int port)
 Creates a socket connection with the server. More...
 
bool Send (std::string data)
 Sends an XML message to the server. More...
 
std::string Receive (int size)
 Returns data received from the server. More...
 
bool SearchForCallBacks (int timeout)
 Wait (timeout) for callbacks from the server. More...
 
void Close ()
 Closes the socket with the server.
 

Public Attributes

long RequestHandle
 Current request identifier.
 

Private Attributes

int sock
 Socket connection with the server.
 
std::string address
 Address of the server.
 
int port
 XML-RPC port of the server.
 
struct sockaddr_in server
 Server/socket information.
 

Detailed Description

Socket connection with server.

Original version of class by Silver Moon. Last updated on September 11th, 2012. Retrieved from: http://www.binarytides.com/code-a-simple-socket-client-class-in-c/

Member Function Documentation

bool TcpClient::Connect ( std::string  address,
int  port 
)

Creates a socket connection with the server.

Returns whether the connection was successfully established.

Parameters
addressAddress of the server (either hostname or IP address).
portXML-RPC port of the server.
std::string TcpClient::Receive ( int  size = 512)

Returns data received from the server.

Parameters
sizeSize of the message expected.
bool TcpClient::SearchForCallBacks ( int  timeout)

Wait (timeout) for callbacks from the server.

Parameters
timeoutTimeout in microseconds.
bool TcpClient::Send ( std::string  data)

Sends an XML message to the server.

Returns whether the message was properly sent.

Parameters
dataXML message to send.

The documentation for this class was generated from the following files: