pmg has asked for the wisdom of the Perl Monks concerning the following question:

I need to write an application on Linux and Windows which uses lots of unblocked sockets. I am using ActiveState for Windows.

I would prefer to use IO::All because it looks really cool, so can I how do I set non-blocking mode there.

If IO::All is not suitable, what is the best way of setting unblocking mode.

Thanks

Peter

Replies are listed 'Best First'.
Re: unblocking sockets
by Zaxo (Archbishop) on Jul 09, 2007 at 23:11 UTC

    This example comes from perldoc -f fcntl:

    use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK); $flags = fcntl(REMOTE, F_GETFL, 0) or die "Can't get flags for the socket: $!\n"; $flags = fcntl(REMOTE, F_SETFL, $flags | O_NONBLOCK) or die "Can't set flags for the socket: $!\n";
    REMOTE there is the socket handle. You may need to dereference if you have a lexical handle ( *{$sock) ).

    After Compline,
    Zaxo

Re: unblocking sockets
by dmitri (Priest) on Jul 10, 2007 at 00:05 UTC
    Check out Event::Lib, which is a wrapper around libevent. This will really make your non-blocking IO programming a breeze.