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
UDPSocket Class Reference
This is a C++ abstraction for UDP networking sockets. More...
#include <UDPSocket.h>
Inherits Socket.
Public Member Functions | |
UDPSocket () | |
Instantiate a UDP Socket. | |
int | bind (int port) |
Bind a UDP Server Socket to a specific port For a listening socket, bind the socket to the following port. | |
int | sendTo (UDPPacket &packet, int timeout_ms=0) |
Send a packet to the remote host. | |
int | receiveFrom (UDPPacket &packet, int timeout_ms=0) |
Receive data from a remote host. |
Detailed Description
This is a C++ abstraction for UDP networking sockets.
Definition at line 29 of file UDPSocket.h.
Constructor & Destructor Documentation
UDPSocket | ( | ) |
Instantiate a UDP Socket.
Definition at line 25 of file UDPSocket.cpp.
Member Function Documentation
int bind | ( | int | port ) |
Bind a UDP Server Socket to a specific port For a listening socket, bind the socket to the following port.
- Parameters:
-
port The port to listen for incoming connections on, using 0 here will select a random port.
- Returns:
- 0 on success, -1 on failure.
Definition at line 33 of file UDPSocket.cpp.
int receiveFrom | ( | UDPPacket & | packet, |
int | timeout_ms = 0 |
||
) |
Receive data from a remote host.
If a message is too long to fit in the supplied packet, excess bytes are discarded.
- Parameters:
-
packet UDP Packet received from the remote host 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 67 of file UDPSocket.cpp.
int sendTo | ( | UDPPacket & | packet, |
int | timeout_ms = 0 |
||
) |
Send a packet to the remote host.
- Parameters:
-
packet UDP Packet to be sent to the remote host 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 53 of file UDPSocket.cpp.
Generated on Wed Jul 27 2022 19:46:00 by
