Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

unblocking sockets

by pmg (Novice)
on Jul 09, 2007 at 18:53 UTC ( #625684=perlquestion: print w/replies, xml ) Need Help??

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://625684]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2021-04-16 14:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?