Hey there,
I've had this problem for a little bit, and it is now time to track it down, as its become obscenely troublesome.
Premise:
I am using sockets under WinSock2 to retrieve an XML page and parse it for use.
Problem:
My socket recv() call intermittently blocks indefinately. I cannot determine a pattern to when it decides its going to block forever, but I speculate it has to do with the response time of the server? There server is a off-site box that operates with (an average) of less than 50ms ping to the development box.
Details:
Code:if ( WSAStartup( MAKEWORD( 2, 2 ), &wsaData ) ) return; if ( ( ConnectSocket = socket( AF_INET, SOCK_STREAM, IPPROTO_TCP ) ) == INVALID_SOCKET ) return; if ( connect( ConnectSocket, (sockaddr *) &clientService, sizeof( clientService ) ) == SOCKET_ERROR ) return; /* ... */ send( ConnectSocket, outBuffer, strlen( outBuffer ), 0 ); shutdown( ConnectSocket, 0x01 ); do { bytes = recv( ConnectSocket, inBuffer, 1024, 0 ); if ( bytes > 0 ) { /* ... */ } else if ( bytes < 0 ) { Disconnect( ); return WSAGetLastError( ); } /* ... */ } while ( bytes > 0 ); /* ... */ closesocket( ConnectSocket ); WSACleanup( );



LinkBack URL
About LinkBacks





