|FreeRTOS+UDP was removed from the FreeRTOS kernel download from FreeRTOS V10.1.0. See the FreeRTOS+TCP stack, which can be configured for UDP only use, as an alternative.|
[FreeRTOS Embedded IP Stack API]
BaseType_t FreeRTOS_bind( xSocket_t xSocket, struct freertos_sockaddr *pxAddress, socklen_t xAddressLength );The Network Addressing and Binding sections of the Embedded Networking Basics and Glossary page provide an introduction to the topic of socket binding.
Binds a socket to a local port number. Binding a socket associates a socket with a port number on the local IP address, resulting in the socket receiving all the data that is sent to that IP address and port number combination.
Port numbers above 49152 are considered private numbers available to the IP stack for dynamic allocation, and should therefore be avoided.
Specifying a port number of 0 will result in the socket being bound to a port number from the private range.
For convenience, if ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 in FreeRTOSIPConfig.h, then calling FreeRTOS_sendto() on a socket that has not first been bound to a port number will also result in the socket being bound to a port number from the private range.
FreeRTOS+UDP does not [currently] use all the function parameters. The parameters that are not used are retained in the function’s prototype to ensure consistency with the expected standard Berkeley sockets API, and to ensure compatibility with future versions of FreeRTOS+UDP.
The handle of the socket that is being bound to an address. The socket
must have previously been created by a successful call to
A pointer to a freertos_sockaddr structure that
contains the details of the port number being bound to.
See the provided example.
Not currently used, but should be set to
sizeof( struct freertos_sockaddr ) to ensure future
If the bind was successful then 0 is returned (0 is the standard Berkeley sockets success return value, contrary to the FreeRTOS standard where 0 means fail!).
FREERTOS_EADDRINUSE is returned if an attempt is made to bind to a port that is already in use.
FREERTOS_ENOBUFS is returned if there was insufficient FreeRTOS heap memory to complete the bind operation.
FREERTOS_EINVAL is returned if the socket is already bound.
FREERTOS_EADDRNOTAVAIL is returned if pxAddress is NULL.
See the example on the FreeRTOS_socket() API documentation page.