Forums » Community Projects

WSAEWOULDBLOCK

Dec 27, 2007 blacknet link
This is perhaps the most annoying error code you could ever receive.

from msn.

WSAEWOULDBLOCK
10035


Resource temporarily unavailable.

This error is returned from operations on nonblocking sockets that cannot be completed immediately, for example recv when no data is queued to be read from the socket. It is a nonfatal error, and the operation should be retried later. It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a nonblocking SOCK_STREAM socket, since some time must elapse for the connection to be established.

So anyone have a good way to handle this error?

Ed
Dec 27, 2007 a1k0n link
Yes, by buffering and setting read/write callbacks.

Are you still getting this in response to a connection, or is this in response to a send or receive call?
Dec 27, 2007 blacknet link
I make a connect attempt. the other side never receives the attempt.
Dec 27, 2007 blacknet link
Just learned the SetupLineInputHandlers function is never reached
Dec 27, 2007 a1k0n link
Can you do me a favor and write a minimal test lua script which repeatably demonstrates this error? I'll need to look at the VO code to fix it.
Dec 27, 2007 blacknet link
:FIX:

the problem is the delay in connection. the WOULDBLOCK message means "some time must elapse for the connection to be established."

solution is to add a delay

in tcpsock.lua at:
local err = conn.tcp:GetSocketError()
if err then
if string.find(err,'WSAEWOULDBLOCK') then
for count = 1,1000000 do end
err = conn.tcp:GetSocketError()
end
end

the for loop on my test boxes yields 100% rsults each and every time with NO block message. I am also checking another type of loop as well.

A timer here would not work at all.

Ed
Dec 27, 2007 a1k0n link
Ray figured it out. The error it's getting is actually totally unrelated to the socket you are connecting with, since WinSock doesn't have a way to check the error status of a particular socket (or if it does, we're not using it). So... in my tcpsock.lua, inside the connecthandler callback in SetupLineInputHandlers, just delete the error checking (local err = conn.tcp:GetSocketError() stuff), since it won't work anyway under Windows.

The Vendetta client code regularly generates EWOULDBLOCK conditions, since it reads the UDP socket input until it would block.
Dec 27, 2007 blacknet link
that works as well.