Question about recv() in Winsock
-
Hello, I am using recv() in my Server, cout << "First recv..." << endl; recv(clientS, r, 6, 0); cout << "Second recv..." << endl; recv(clientS, r, 6, 0); and in the client side, I do not send any message after I have connected to the server. However, the output of the server is First recv... Second recv... I just wonder that the recv() should be blocking operation, but how come it does not wait for the message come before it goes to another statement? Thanks for help! Nachi
-
Hello, I am using recv() in my Server, cout << "First recv..." << endl; recv(clientS, r, 6, 0); cout << "Second recv..." << endl; recv(clientS, r, 6, 0); and in the client side, I do not send any message after I have connected to the server. However, the output of the server is First recv... Second recv... I just wonder that the recv() should be blocking operation, but how come it does not wait for the message come before it goes to another statement? Thanks for help! Nachi
again MSDN: If no incoming data is available at the socket, the recv call blocks and waits for data to arrive according to the blocking rules defined for WSARecv with the MSG_PARTIAL flag not set unless the socket is nonblocking. In this case, a value of SOCKET_ERROR is returned with the error code set to WSAEWOULDBLOCK. The select, WSAAsyncSelect, or WSAEventSelect functions can be used to determine when more data arrives. Papa Murex Co. while (TRUE) Papa.WillLove ( Bebe ) ;
-
again MSDN: If no incoming data is available at the socket, the recv call blocks and waits for data to arrive according to the blocking rules defined for WSARecv with the MSG_PARTIAL flag not set unless the socket is nonblocking. In this case, a value of SOCKET_ERROR is returned with the error code set to WSAEWOULDBLOCK. The select, WSAAsyncSelect, or WSAEventSelect functions can be used to determine when more data arrives. Papa Murex Co. while (TRUE) Papa.WillLove ( Bebe ) ;