[Note: This page does not describe the callback or zero copy interfaces,
which are available for expert users.]
is used to receive data from a TCP socket.
FreeRTOS_recv() cannot be
called until the TCP socket has been created, configured, bound
and connected to a remote socket.
The source code below demonstrates how to use FreeRTOS_recv() to place
received data into a buffer. In the example it is assumed that the
socket has already been created and connected.
#define BUFFER_SIZE 512
static void prvEchoClientRxTask( void *pvParameters )
static char cRxedData[ BUFFER_SIZE ];
xSocket = ( Socket_t ) pvParameters;
for( ;; )
lBytesReceived = FreeRTOS_recv( xSocket, &cRxedData, BUFFER_SIZE, 0 );
if( lBytesReceived > 0 )
prvPorcessData( cRxedData, lBytesReceived );
else if( lBytesReceived == 0 )
FreeRTOS_shutdown( xSocket, FREERTOS_SHUT_RDWR );
while( FreeRTOS_recv( xSocket, pcBufferToTransmit, xTotalLengthToSend, 0 ) >= 0 )
vTaskDelay( pdTICKS_TO_MS( 250 ) );
FreeRTOS_closesocket( xSocket );
xTaskDelete( NULL );
Example using FreeRTOS_recv()
Back to the RTOS TCP networking tutorial index
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.