Networking sockets are second-class objects under Win32 (they aren't integrated into the C RTL's I/O subsystem nor into the operating system). So the error codes are only found in WinSock.h and don't get put into the C RTL's errno and they are called things like "WSAEWOULDBLOCK".
Perl does copy them into $! but that isn't very handy because a bug in Perl causes:
print $!=10035
to print simply "Unknown error". It should at least report "Unknown error (10035)"! I actually started work on a patch for this that would also allow me to write a module that, when used, would cause it to print "WinSock operation would block" (for example). I ran into some snags (like "use Errno" using %! in a strange way so that I couldn't use it and so had to come up with some global varable name) and never finished the patch so it looks like even the "Unknown error (10035)" part of the patch got dropped. ):
But this is all relatively unimportant compared to the fact that you'll have quite a bit of trouble getting sockets to be non-blocking under Win32. I've seen a couple of proposals for rather ugly hacks that have been reported to work (I just tried to find them but it will take me some more time in Super Search to come up with them) as well as some ideas on patching Perl to make the standard SOCK->blocking(0) work.
So we should probably patch the Errno.pm-generating code to pull in the non-overlapping WSAE* codes for compatability...
I'm sorry that this isn't my first priority right now so that some of these good patch ideas aren't likely to get implemented by me soon. But if anyone feels qualified do some patching work, I'd be happy to offer guidance. /:
-
tye
(but my friends call me "Tye")
|