Valhalla Legends Forums Archive | General Programming | Nonblocking Sockets

AuthorMessageTime
iago
I think I already know the answer to this, so I'm just confirming:

I'm using nonblocking sockets, and when I try recieving data it returns SOCKET_ERROR with the error code WSAEWOULDBLOCK. This is the code I'm using:
[code]void WS::SetSocketBlocking(DWORD Block)
{
   if(ioctlsocket(s, FIONBIO, &Block) == SOCKET_ERROR)
   {
      if(ErrorCallback)
         ErrorCallback("Error setting socket blocking (ioctlsocket)", WSAGetLastError());
   }
}[/code]

Anyway, I'm just assuming that I should just ignore this error because it's just telling me that there just wasn't any data waiting, but I'm just making sure that this isnt' a horrible, horrible error.

Thanks!

-iago
July 2, 2003, 9:35 AM
DarkMinion
WSAEWOULDBLOCK should just be ignored, yes, it is not a horrible, horrible error :P

[code]
      if(dwWaitResult == WAIT_OBJECT_0 && bBNETConnected){
         int iRecvLen = recv(sBNET, szRecvBuffer, sizeof(szRecvBuffer), 0);
         if(!iRecvLen || iRecvLen == SOCKET_ERROR && WSAGetLastError() != WSAEWOULDBLOCK)
            break;
         ParseBNET(szRecvBuffer, iRecvLen);
      }
[/code]
July 2, 2003, 12:38 PM
Yoni
WSAEWOULDBLOCK means "your call succeeded now, but it might fail later since the action you requested hasn't completed yet." Usually you can ignore it safely.
July 2, 2003, 2:19 PM
iago
All right, thanks! :-)
July 2, 2003, 4:51 PM

Search