我使用ioctlsocket()函數,使我的插座非阻塞的,但是當我打電話recvfrom的(),我得到的錯誤10035(WSAEWOULDBLOCK
)。recvfrom的()錯誤10035使用非阻塞套接字
u_long mode = 1;
ioctlsocket(newSocketIdentifier, FIONBIO, &mode);
while(1)
{
if((recv_len = recvfrom(newSocketIdentifier, receiveBuffer, sizeof(receiveBuffer), 0, (struct sockaddr *) &clientSocket, &clientSocketLength)) == SOCKET_ERROR)
{
char err[128];
itoa(WSAGetLastError(),err,10);
MessageBox(NULL,"Could not Receive Data",err,MB_ICONINFORMATION);
BREAK;
}
}
任何人都可以解釋爲什麼發生這種情況? :(
I/O調用可能會失敗您確定*成功*因爲使套接字非阻塞? – unwind
如果當前沒有可用的數據,您將WSAEWOULDBLOCK放在非阻塞套接字上,這是正常行爲 –