Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: nonblocking io

by Anarion (Hermit)
on Oct 11, 2001 at 12:05 UTC ( [id://118167]=note: print w/replies, xml ) Need Help??


in reply to nonblocking io

If you want to use non-blocking in sockets, you can use select by yourself, or just use IO::Select.

There are three solutions:
- fork
- multiplex the conections with just one process
- use threads

Here's an example of the multiplexion, that i read in advanced perl programing:

use IO::Socket; use IO::Select; my $server = IO::Socket::INET->new ... my $select = IO::Select->new; my $time = 0.5; # How time it waits to check for a new conection $select->add($server); while(1) { my ($sockets_ready) = IO::Select->select($select, undef, undef, $time); foreach my $sock (@$sockets_ready) { if ($sock == $server) { # Accept a new conection my $new_sock = $sock->accept(); $select->add($new_sock); } else { # Its an old conection .... } }


I dont test the code, hope it works.
$anarion=\$anarion;

s==q^QBY_^=,$_^=$[x7,print

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://118167]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-19 04:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found