Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Socket by
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:
-
host The host to connect to. It can either be an IP Address or a hostname that will be resolved with DNS. port The 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:
-
data The buffer in which to store the data received from the host. length The maximum length of the buffer. timeout The 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:
-
data The buffer in which to store the data received from the host. length The maximum length of the buffer. timeout The 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:
-
data The buffer to send to the host. length The length of the buffer to send. timeout The 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:
-
data The buffer to send to the host. length The length of the buffer to send. timeout The 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.
Generated on Wed Jul 27 2022 19:46:00 by
