heinbali01 wrote on Thursday, August 16, 2018:
You are setting the send time-out on xConnectedSocket
, but you do not show the actual value of xSendTimeout
.
Despite that, I can not see an apparent reason why FreeRTOS_send()
would not send-out the data contained in the variable page
.
Have you defined ipconfigDRIVER_INCLUDED_TX_IP_CHECKSUM
as 0
?
If it is non-zero, either your network driver must calculate and set the checksums ( IP and protocol ), or the EMAC must set it.
Your application is likely to run until all resources are exhausted: after sending the data, the variable xConnectedSocket
will be overwritten and the handle to the old socket becomes unreachable.
If you want to keep it simpler ( for testing ), allow only a single client:
FreeRTOS_listen( xListeningSocket, 1 );
And keep on reading from xConnectedSocket
until you get a negative value, not equal to -EWOULDBLOCK
:
if( xConnectedSocket != FREERTOS_INVALID_SOCKET )
{
for( ;; )
{
lByteReceived = FreeRTOS_recv( xConnectedSocket, socketRecvBuf, sizeof(socketRecvBuf), 0 );
if( ( lByteReceived < 0 ) && ( lByteReceived != -pdFREERTOS_ERRNO_EWOULDBLOCK ) )
{
/* Break out of the loop in order to receive a new client. */
/* The most probable return code is -pdFREERTOS_ERRNO_ENOTCONN */
break;
}
if( lByteReceived > 0 )
{
/* Send a reply back. */
lBytesSent = FreeRTOS_send(xConnectedSocket, page, sizeof(page), 0);
printf( "Bytes sended: %d\n", lBytesSent );
if( ( lBytesSent < 0 ) && ( lBytesSent != -pdFREERTOS_ERRNO_EWOULDBLOCK ) )
{
/* Send returns a fatal error, break from the loop. */
break;
}
}
}
FreeRTOS_closesocket( xConnectedSocket );
xConnectedSocket = FREERTOS_INVALID_SOCKET;
}
You set FREERTOS_SO_RCVTIMEO
of the listening socket. That value will be inherited by the child socket.
Give it a reasonable value unequal to zero.
If you want to see a simple HTTP server that works well, please download :
https://freertos.org/FreeRTOS-Labs/downloads/160919_FreeRTOS_Labs.zip?dl=0
and have a look at FreeRTOS-Plus\Source\FreeRTOS-Plus-TCP\protocols\