AnsweredAssumed Answered

Unexpected behavior with RTCS_selectset() and accept() for TCP server socket

Question asked by Tim Meyer on Mar 22, 2012
Latest reply on Nov 20, 2012 by netra

Hi all.


I am running a Kinetis K60 Tower.

I have a simple TCP server setup to listen for incoming client connections. I am able to detect (with RTCS_selectset) and accept incoming client connections as expected for a few connections (say 10-15) . Then randomly upon attempting to connect to the server, the listening sever socket enters a state where RTCS_selectset() will immediately return indicating there is a client ready, accept return immediately with return code RTCS_SOCKET_ERROR. However when calling RTCS_geterror(server_socket) I get RTCS_OK. It is like select says a client is waiting to connect, and accept is trying but failing to accpet the connection - but not providing an error.

Furthermore when this state is entered, even shutting down and and creating a new server socket continue to behave this way.  


Any suggestions?





while(retry){client_socket = RTCS_selectset(&server_socket, 1, BSP_ETHERNET_CONNECTION_TIMEOUT);  if(client_socket == RTCS_SOCKET_ERROR)   {      break;  }   else if(client_socket == server_socket)   {   client_socket = accept(server_socket, NULL, NULL);    if(client_socket == RTCS_SOCKET_ERROR)    {    int status = RTCS_geterror(server_socket);    if (status == RTCS_OK)     {     /// keeps ending up here when in bad state    }....