wavenator has asked for the wisdom of the Perl Monks concerning the following question:
use IO::Socket; # Create the receiving socket my $s = new IO::Socket::INET ( LocalPort => 7070, Proto => 'tcp', Listen => 16, Reuse => 1, ); die "Could not create socket: $!\n" unless $s; my ($ns, $buf); use IO::Select; $read_set = new IO::Select(); $read_set->add($s); while (1) { # forever my ($rh_set) = IO::Select->select($read_set, undef, undef, 0); foreach $rh (@$rh_set) { $rh->autoflush(1); if ($rh == $s) { $ns = $rh->accept(); $read_set->add($ns); } if ($rh == $ns) { $buf = <$rh>; print "$buf"; } else{ $msg=<STDIN>; print $ns "$msg"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: make my code non block
by Somni (Friar) on Oct 12, 2007 at 00:48 UTC | |
by wavenator (Novice) on Oct 12, 2007 at 06:50 UTC | |
|
Re: make my code non block
by chrism01 (Friar) on Oct 12, 2007 at 00:40 UTC | |
|
Re: make my code non block
by BrowserUk (Patriarch) on Oct 12, 2007 at 01:28 UTC | |
by wavenator (Novice) on Oct 12, 2007 at 06:39 UTC | |
by BrowserUk (Patriarch) on Oct 12, 2007 at 07:31 UTC |