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")

In reply to (tye)Re: Win32 equivalant to Errno 'EWOULDBLOCK' by tye
in thread Win32 equivalant to Errno 'EWOULDBLOCK' by otijim

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.