The User Datagram Protocol (UDP) layer provides connectionless best effort data block delivery.
void ltrx_udp_socket_close |
( |
struct ltrx_ip_socket * |
sock | ) |
|
bool ltrx_udp_socket_get_received_packet_information |
( |
struct ltrx_ip_socket * |
sock, |
|
|
struct ltrx_ip_address * |
optRemoteAddress, |
|
|
uint16_t * |
optRemotePort |
|
) |
| |
Get received packet information.
- Return values
-
true | Success. |
false | Failed. |
- Parameters
-
[in] | sock | The socket. |
[out] | optRemoteAddress | If present, gets filled in with the remote IP address. Otherwise, set to NULL . |
[out] | optRemotePort | If present, gets filled in with the remote IP port. Otherwise, set to NULL . |
bool ltrx_udp_socket_is_active |
( |
struct ltrx_ip_socket * |
sock | ) |
|
Check if the UDP socket is active.
- Return values
-
true | Yes, it is active. |
false | No, it is not active. |
- Parameters
-
bool ltrx_udp_socket_multicast_join |
( |
uint8_t |
zeroBasedInterface, |
|
|
struct ltrx_ip_address * |
groupAddress |
|
) |
| |
Multicast join.
- Return values
-
true | Success. |
false | Failed. |
- Parameters
-
[in] | zeroBasedInterface | Index for the desired interface.
NETS_SOFTAP_START for ap0.
NETS_ETHERNET_START for eth0.
NETS_WLAN_START for wlan0.
|
[in] | groupAddress | The group address to join. |
struct ltrx_ip_socket* ltrx_udp_socket_open |
( |
uint8_t |
zeroBasedInterface, |
|
|
uint16_t |
optLocalPort |
|
) |
| |
Open socket.
- Returns
- Socket pointer.
- Return values
-
- Parameters
-
[in] | zeroBasedInterface | Index for the desired interface.
NETS_SOFTAP_START for ap0.
NETS_ETHERNET_START for eth0.
NETS_WLAN_START for wlan0.
|
[in] | optLocalPort | If non-zero, specifies the local port. If 0 , a random unused UDP port number will be assigned. |
Open socket with options.
- Returns
- Socket pointer.
- Return values
-
- Parameters
-
[in] | luso | Specifies the options. |
bool ltrx_udp_socket_reply |
( |
struct ltrx_ip_socket * |
socket, |
|
|
size_t |
length |
|
) |
| |
Send reply.
Prior to this call, user has received a UDP packet via ltrx_ip_socket_receive(), learning the buffer location and receive length. The user modifies the buffer, then calls ltrx_udp_socket_reply() providing the length to send.
The reply may be longer than the received packet, up to the maximum UDP packet length. The user must take care not to write the buffer beyond the maximum length. It is possible to call ltrx_ip_socket_receive() more than once in a single packet if the receive length is limited. To avoid confusion regarding the beginning (and hence the end) of the buffer, it is recommended to call ltrx_ip_socket_receive() exclusively with the maximum length of 0xffffffff on any socket that may call ltrx_udp_socket_reply().
- Return values
-
true | Success. |
false | Failed. |
- Parameters
-
[in,out] | socket | The socket. |
[in] | length | Length of data to send. |
bool ltrx_udp_socket_send |
( |
struct ltrx_ip_socket * |
sock, |
|
|
const struct ltrx_ip_address * |
address, |
|
|
uint16_t |
port, |
|
|
const void * |
data, |
|
|
size_t |
length |
|
) |
| |
Send data.
- Return values
-
true | Success. |
false | Failed. |
- Parameters
-
[in,out] | sock | The socket. |
[in] | address | Destination IP address. |
[in] | port | Destination IP port. |
[in] | data | Data to send. |
[in] | length | Length of data to send. |