in reply to Nonblocking sockets on Win32

It's a known bug.

This *seems* to work. (The side-effects are unknown to me.)

sub POSIX_FIONBIO () { (0x80000000 | (4<<16) | (ord('f')<<8) | 126) } + # 0x8004667E ioctl($sock, POSIX_FIONBIO, pack("I", 1)) or $! == 0 # ** or die(...); # ** - ioctl is returning undef, # yet both $! and $^E are 0. # I don't know what this means.

Replies are listed 'Best First'.
Re^2: Nonblocking sockets on Win32
by renodino (Curate) on Nov 29, 2005 at 00:07 UTC
    Ahh, thnx, that did it...with one tiny change: I had to explicitly clear $! before the call; apparently, ioctl() isn't clearing it on its own.

    I had tried a similar recommendation which said the param value had to be a ref:

    $nonblock = 1; ioctl($sock, POSIX_FIONBIO, \$nonblock); # !!WRONG
    but that would only set nonblock, but couldn't set back to blocking.

    And an FYI: this worked with a IO::Socket::INET handle.

      This node is also particular informative - Re: (to be updated) (tye)Re: Non blocking socket open - I used some of the code therein to build a cross-platform, non-blocking network event engine which has proven to be particularly robust since deployment.

       

      perl -le "print unpack'N', pack'B32', '00000000000000000000001000000000'"

        Thnx, I saw that prior to ikegami's pointer, but some of the comments scared em off. Now that I grok the ioctl() bit, the other part now makes more sense.

        The delta is the nonblocking connect() which (hopefully) I won't need anytime soon. (tho I may have a use for it in another app for which some users have griped about wanting a smaller timeout when the peer isn't available.)