a library to use GPRS like ethernet or wifi, which makes it possible to connect to the internet with your GPRS module

Dependencies:   BufferedSerial

Dependents:   ThinkSpeak_Test roam_v1 roam_v2 finalv3

Fork of GPRSInterface by wei zou

Embed: (wiki syntax)

« Back to documentation index

TCPSocketConnection Class Reference

TCPSocketConnection Class Reference

TCP socket connection. More...

#include <TCPSocketConnection.h>

Inherits Socket.

Public Member Functions

 TCPSocketConnection ()
 TCP socket connection.
int connect (const char *host, const int port)
 Connects this TCP socket to the server.
bool is_connected (void)
 Check if the socket is connected.
int send (char *data, int length)
 Send data to the remote host.
int send_all (char *data, int length)
 Send all the data to the remote host.
int receive (char *data, int length)
 Receive data from the remote host.
int receive_all (char *data, int length)
 Receive all the data from the remote host.
int close ()
 Close the socket file descriptor.

Friends

class TCPSocketServer

Detailed Description

TCP socket connection.

Definition at line 30 of file TCPSocketConnection.h.


Constructor & Destructor Documentation

TCP socket connection.

Definition at line 25 of file TCPSocketConnection.cpp.


Member Function Documentation

int close (  ) [inherited]

Close the socket file descriptor.

Definition at line 37 of file Socket.cpp.

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

Connects this TCP socket to the server.

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 29 of file TCPSocketConnection.cpp.

bool is_connected ( void   )

Check if the socket is connected.

Returns:
true if connected, false otherwise.

Definition at line 44 of file TCPSocketConnection.cpp.

int receive ( char *  data,
int  length 
)

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.
Returns:
the number of received bytes on success (>=0) or -1 on failure

Definition at line 62 of file TCPSocketConnection.cpp.

int receive_all ( char *  data,
int  length 
)

Receive all the data from the remote host.

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

Definition at line 67 of file TCPSocketConnection.cpp.

int send ( char *  data,
int  length 
)

Send data to the remote host.

Parameters:
dataThe buffer to send to the host.
lengthThe length of the buffer to send.
Returns:
the number of written bytes on success (>=0) or -1 on failure

Definition at line 52 of file TCPSocketConnection.cpp.

int send_all ( char *  data,
int  length 
)

Send all the data to the remote host.

Parameters:
dataThe buffer to send to the host.
lengthThe length of the buffer to send.
Returns:
the number of written bytes on success (>=0) or -1 on failure

Definition at line 57 of file TCPSocketConnection.cpp.