[ ]
 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Homepage FreeRTOS Labs FreeRTOS+TCP FreeRTOS+FAT Contact / Enquiries

FreeRTOS+TCP is still in the lab
FreeRTOS+TCP is already used in commercial products and we encourage you to try it yourself. Be aware however that we are still refining its design, and the source code and documentation do not yet meet Real Time Engineers Ltd's strict quality standards.
Please use the forum for support, feedback and ideas, or contact us directly if you have a specific business interest.


[FreeRTOS+TCP API Reference]

BaseType_t FreeRTOS_bind( Socket_t xSocket,
                          struct freertos_sockaddr *pxAddress,
                          socklen_t xAddressLength );
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.

The Network Addressing and Binding sections of the Embedded Networking Basics and Glossary page provide an introduction to the topic of socket binding.

Port numbers above 49408 (0xC100) to 65280 (0xff00) are considered private numbers available to the IP stack for dynamic allocation, and should therefore be avoided. Specifying a port number of 0 or passing pxAddress as NULL 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_send() 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+TCP 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+TCP.


xSocket   The handle of the socket that is being bound to an address. The socket must have previously been created by a successful call to FreeRTOS_socket().

pxAddress   A pointer to a freertos_sockaddr structure that contains the details of the port number being bound to. See the provided example.

xAddressLength   Not currently used, but should be set to sizeof( struct freertos_sockaddr ) to ensure future compatibility.


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_EINVAL is returned if the socket did not get bound, probably because the specified port number was already in use.

-FREERTOS_ECANCELED is returned if the calling RTOS task did not get a response from the IP RTOS task to the bind request.

Example usage:

See the examples on the FreeRTOS+TCP networking tutorial page, and on the FreeRTOS_socket() API documentation page.

[ Back to the top ]    [ About FreeRTOS ]    [ FreeRTOS Labs Sitemap ]    [ Main FreeRTOS Sitemap ]    [ ]

Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.