• Welcome to Valhalla Legends Archive.
 

Nonblocking Sockets

Started by iago, July 02, 2003, 04:35 AM

Previous topic - Next topic

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:
void WS::SetSocketBlocking(DWORD Block)
{
   if(ioctlsocket(s, FIONBIO, &Block) == SOCKET_ERROR)
   {
      if(ErrorCallback)
         ErrorCallback("Error setting socket blocking (ioctlsocket)", WSAGetLastError());
   }
}


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
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


DarkMinion

WSAEWOULDBLOCK should just be ignored, yes, it is not a horrible, horrible error  :P


      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);
      }

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.

iago

This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*