woosley has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; use Errno qw/EWOULDBLOCK/; use IO::Socket; #my $socket = IO::Socket::INET->new( 'localhost:5555', ) or die "Faile +d"; STDIN->blocking(0); my $data; while (1) { my $rc = sysread( STDIN, $data, 1024 ); if ( defined $rc ) { if ( $rc > 0 ) { # print $socket $data; print $data,"\n"; } else { # close $socket; } } elsif ( $! == EWOULDBLOCK ) { next; } else { die "sysread error:$!"; } } #close $socket;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Non-blocking reading on STDIN?
by johngg (Canon) on Apr 19, 2009 at 11:30 UTC | |
|
Re: Non-blocking reading on STDIN?
by betterworld (Curate) on Apr 19, 2009 at 10:06 UTC | |
by woosley (Beadle) on Apr 19, 2009 at 14:08 UTC | |
|
Re: Non-blocking reading on STDIN?
by mr_mischief (Monsignor) on Apr 19, 2009 at 07:31 UTC | |
by woosley (Beadle) on Apr 19, 2009 at 14:03 UTC |