Neal Horman / Socket

Fork of Socket by mbed official

Embed: (wiki syntax)

« Back to documentation index

TCPSocketConnection Class Reference

TCPSocketConnection Class Reference

This is a C++ abstraction for TCP networking sockets. More...

#include <TCPSocketConnection.h>

Inherits Socket, and Endpoint.

Public Member Functions

 TCPSocketConnection ()
 Instantiate a TCP Socket.
int connect (const char *host, const int port)
 Connect the TCP Socket to the following host.
int send (char *data, int length, int timeout_ms=0)
 Send data to the remote host.
int send_all (char *data, int length, int timeout_ms=0)
 Send data to the remote host.
int receive (char *data, int length, int timeout_ms=0)
 Receive data from the remote host.
int receive_all (char *data, int length, int timeout_ms=0)
 Receive data from the remote host.

Detailed Description

This is a C++ abstraction for TCP networking sockets.

Definition at line 28 of file TCPSocketConnection.h.


Constructor & Destructor Documentation

Instantiate a TCP Socket.

Definition at line 24 of file TCPSocketConnection.cpp.


Member Function Documentation

int connect ( const char *  host,
const int  port 
)

Connect the TCP Socket to the following host.

Parameters:
hostThe host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS.
portThe host's port to connect to.
Returns:
0 on success, -1 on failure.

Definition at line 28 of file TCPSocketConnection.cpp.

int receive ( char *  data,
int  length,
int  timeout_ms = 0 
)

Receive data from the remote host.

Parameters:
dataThe buffer in which to store the data received from the host.
lengthThe maximum length of the buffer.
timeoutThe maximum amount of time in ms to wait while trying to receive data.
Returns:
the number of received bytes on success (>=0) or -1 on failure

Definition at line 84 of file TCPSocketConnection.cpp.

int receive_all ( char *  data,
int  length,
int  timeout_ms = 0 
)

Receive data from the remote host.

Parameters:
dataThe buffer in which to store the data received from the host.
lengthThe maximum length of the buffer.
timeoutThe maximum amount of time in ms to wait while trying to receive data.
Returns:
the number of received bytes on success (>=0) or -1 on failure

Definition at line 99 of file TCPSocketConnection.cpp.

int send ( char *  data,
int  length,
int  timeout_ms = 0 
)

Send data to the remote host.

Parameters:
dataThe buffer to send to the host.
lengthThe length of the buffer to send.
timeoutThe maximum amount of time in ms to wait while trying to send the buffer.
Returns:
the number of written bytes on success (>=0) or -1 on failure

Definition at line 43 of file TCPSocketConnection.cpp.

int send_all ( char *  data,
int  length,
int  timeout_ms = 0 
)

Send data to the remote host.

Parameters:
dataThe buffer to send to the host.
lengthThe length of the buffer to send.
timeoutThe maximum amount of time in ms to wait while trying to send the buffer.
Returns:
the number of written bytes on success (>=0) or -1 on failure

Definition at line 58 of file TCPSocketConnection.cpp.