Jump to content

amunra

Members
  • Posts

    2
  • Joined

  • Last visited

amunra's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. amunra

    recv timeout

    Hi all, I have got the same problem here. I have added some trace to my code and this is what I have so far.. * calling recv() after opening the socket and before any other network IO works fine. The recv() funciton does not block and functions as expected. * After I call send() I receive a load of data. Again this works as expected. * when the incomming data ends the recv() function hangs on the first call expected to return EWOULDBLOCK. I have tryed using: flag = fcntl( *psocket, F_GETFL, 0 ); fcntl( *psocket, F_SETFL, flag | O_NONBLOCK ); and bytes_read = recv( p->stream_sockets[socket_id].socket, (char*)data, data_sz, MSG_PEEK ) but neither of these make any difference. If the socket is closed by the server while the recv() funtion is hung it still does not return. This implies to me that the recv() function has either crashed or entered an endless loop. I have a 100% repeatable situation and I am happy to help find this bug... Cheers Amun-Ra Hi all, I have managed to create a workaround for this. I downloaded the 0.3c source code and traced the hang into sgIP_sockets.c line 178. It never exits that loop. According to the recv() man page when using the MSG_PEEK flag recv() should not block. So I added the following line just under the sgIP_TCP_Recv() call: if(retval==-1&&flags&MSG_PEEK) retval=0; This makes the recv() function exit with zero bytes when there is nothing to retrieve and the MSG_PEEK flag is set. Then my app can use this flag to see if there is data to get before it calls recieve. This has worked a treat and I hope this fix is intergrated into the next version of the dswifi lib. I also noted this line in the same loop: if(socketlist[socket].flags&SGIP_SOCKET_FLAG_NONBLOCKING) break; But for some reson this condition was not working. Yet as I explained in my previous post it did work when the socket was first opened. I beleive this flag is somehow being reset. This is the real bug all I have done is fixed the MSG_PEEK bug to enable a workaround. Cheers Amunra
  2. amunra

    recv timeout

    Hi all, I have got the same problem here. I have added some trace to my code and this is what I have so far.. * calling recv() after opening the socket and before any other network IO works fine. The recv() funciton does not block and functions as expected. * After I call send() I receive a load of data. Again this works as expected. * when the incomming data ends the recv() function hangs on the first call expected to return EWOULDBLOCK. I have tryed using: flag = fcntl( *psocket, F_GETFL, 0 ); fcntl( *psocket, F_SETFL, flag | O_NONBLOCK ); and bytes_read = recv( p->stream_sockets[socket_id].socket, (char*)data, data_sz, MSG_PEEK ) but neither of these make any difference. If the socket is closed by the server while the recv() funtion is hung it still does not return. This implies to me that the recv() function has either crashed or entered an endless loop. I have a 100% repeatable situation and I am happy to help find this bug... Cheers Amun-Ra
×
×
  • Create New...