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.
TCPSocket Class Reference
This is a simple TCP Socket class. More...
#include <TCPSocket.h>
Public Member Functions | |
| TCPSocket () | |
| Creates a new socket. | |
| ~TCPSocket () | |
| Closes if needed and destroys the socket. | |
| TCPSocketErr | bind (const Host &me) |
| Binds the socket to (local) host. | |
| TCPSocketErr | listen () |
| Starts listening. | |
| TCPSocketErr | connect (const Host &host) |
| Connects socket to host. | |
| TCPSocketErr | accept (Host *pClient, TCPSocket **ppNewTcpSocket) |
| Accepts connection from client and gets connected socket. | |
| int | send (const char *buf, int len) |
| Sends data. | |
| int | recv (char *buf, int len) |
| Receives data. | |
| TCPSocketErr | close () |
| Closes socket. | |
| void | setOnEvent (void(*pMethod)(TCPSocketEvent)) |
| Setups callback. | |
| template<class T > | |
| void | setOnEvent (T *pItem, void(T::*pMethod)(TCPSocketEvent)) |
| Setups callback. | |
| void | resetOnEvent () |
| Disables callback. | |
Detailed Description
This is a simple TCP Socket class.
This class exposes an API to deal with TCP Sockets
Definition at line 71 of file TCPSocket.h.
Constructor & Destructor Documentation
| TCPSocket | ( | ) |
Creates a new socket.
| ~TCPSocket | ( | ) |
Closes if needed and destroys the socket.
Member Function Documentation
| TCPSocketErr accept | ( | Host * | pClient, |
| TCPSocket ** | ppNewTcpSocket | ||
| ) |
Accepts connection from client and gets connected socket.
| TCPSocketErr bind | ( | const Host & | me ) |
Binds the socket to (local) host.
| TCPSocketErr close | ( | ) |
Closes socket.
| TCPSocketErr connect | ( | const Host & | host ) |
Connects socket to host.
| TCPSocketErr listen | ( | ) |
Starts listening.
| int recv | ( | char * | buf, |
| int | len | ||
| ) |
Receives data.
| void resetOnEvent | ( | ) |
Disables callback.
| int send | ( | const char * | buf, |
| int | len | ||
| ) |
Sends data.
| void setOnEvent | ( | void(*)(TCPSocketEvent) | pMethod ) |
Setups callback.
- Parameters:
-
pMethod : callback function
| void setOnEvent | ( | T * | pItem, |
| void(T::*)(TCPSocketEvent) | pMethod | ||
| ) |
Setups callback.
- Parameters:
-
pItem : instance of class on which to execute the callback method pMethod : callback method
Definition at line 125 of file TCPSocket.h.
Generated on Tue Jul 12 2022 20:02:52 by
1.7.2