MSDN は次のコードを提供します。
int iResult;
// Receive until the peer closes the connection
do {
iResult = recv(ConnectSocket, recvbuf, recvbuflen, 0);
if ( iResult > 0 )
printf("Bytes received: %d\n", iResult);
else if ( iResult == 0 )
printf("Connection closed\n");
else
printf("recv failed: %d\n", WSAGetLastError());
} while( iResult > 0 );
iResult は受信したバイト数を保存します! 私の場合、何も受信されなかった場合(または終了に達した場合)に受信がハングするため、このようにすることはできません->したがって、終了条件が一致しません!
何か問題があるか、recv がここでハングするのはなぜですか?
あいさつ