In the server code you shared previously in the [first post],(FreeRTOS + TCP - Client Server communication Fail) you are checking for the validity of the socket returned by FreeRTOS_accept
but it only checks for FREERTOS_INVALID_SOCKET
:
Since you have set your xListeningSocket
’s FREERTOS_SO_RCVTIMEO
to 1 second:
FreeRTOS_setsockopt(xListeningSocket, 0, FREERTOS_SO_RCVTIMEO, &acpt_tout, sizeof(acpt_tout));
But in the debug screen capture you shared in the previous post, there is no check at all inside the server code.
If a timeout (FREERTOS_SO_RCVTIMEO
) occurs before a connection from a remote socket is accepted, then NULL is returned by FreeRTOS_accept
.
So you also need to verify the xConnectedSocket
is not NULL as you set FREERTOS_SO_RCVTIMEO
to be 1 second. In the demo code for server that I shared here before, FREERTOS_SO_RCVTIMEO
is set to portMAX_DELAY
which means the FreeRTOS_accept
waits indefinitely and therefore never times out.