Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Think about Loose Coupling
 
PerlMonks  

Re: nonblocking io

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

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.