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.
void FreeRTOS_FD_CLR( Socket_t xSocket, SocketSet_t xSocketSet, BaseType_t xBitsToClear );
Sockets in a socket set have a number of associated event bits of interest.
An event bit of interest becoming set will cause the socket to unblock a
call to FreeRTOS_select(). Event bits of interest are set using the
API function, and cleared using the FreeRTOS_FD_CLR() API function. If
all the event bits are clear then the socket will be removed from the
ipconfigSUPPORT_SELECT_FUNCTION must be set to 1 in
for FreeRTOS_FD_CLR() to be available.
Each socket member has its own set of event bits, which can be a bitwise
OR combination of the following values:
For a socket that is reading data, the eSELECT_READ event
will be pending in a socket as long as the socket contains
For a socket that is listening for new connections, the
eSELECT_READ event will be pended each time a new connection
The eSELECT_WRITE event will remain pending as long as the
socket has space for writing.
If a TCP socket is actively connecting to a pear the
eSELECT_WRITE event will be triggered as soon as the connection
One the eSELECT_WRITE event has been pended it should either
be disabled, or the caller should write enough data to the
socket so as to completely fill up the transmit buffer -
otherwise the pending eSELECT_WRITE event will not be cleared.
The eSELECT_EXCEPT event will become pending if the socket
The socket having a bit of interest cleared or being
removed from the socket set.
The socket set the socket is a member of.
The bits which should be cleared, use 'eSELECT_ALL' to clear all
bits and remove the socket from the set.
void vConnectExample( )
struct freertos_sockaddr xEchoServerAddress;
const TickType_t xZeroTimeOut = 0;
xSocket = FreeRTOS_socket( FREERTOS_AF_INET, FREERTOS_SOCK_STREAM, FREERTOS_IPPROTO_TCP );
xSocketSet = FreeRTOS_CreateSocketSet()( );
FreeRTOS_FD_SET( xSocket, xSocketSet, eSELECT_WRITE );
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_RCVTIMEO, &xZeroTimeOut, sizeof( xZeroTimeOut ) );
FreeRTOS_setsockopt( xSocket, 0, FREERTOS_SO_SNDTIMEO, &xZeroTimeOut, sizeof( xZeroTimeOut ) );
xEchoServerAddress.sin_port = FreeRTOS_htons( echoECHO_PORT );
xEchoServerAddress.sin_addr = FreeRTOS_inet_addr_quick( configECHO_SERVER_ADDR0,
FreeRTOS_connect( xSocket, &xEchoServerAddress, sizeof( xEchoServerAddress ) );
if( FreeRTOS_select( xSocketSet, 30000 ) != 0 )
BaseType_t xMask = FreeRTOS_FD_ISSET ( xSocket, xSocketSet );
if( xMask != 0 )
FreeRTOS_FD_CLR( xSocket, xSocketSet, eSELECT_WRITE );
FreeRTOS_FD_SET( xSocket, xSocketSet, eSELECT_READ );
Example use of the FreeRTOS_FD_SET / FD_CLR / FD_ISSET() API functions