Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I'm sure this is something simple, just a misplace of the timer(); thanksprint "Opening connection to $config{server} on port $config{port} ... +\n"; $sock = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $config{server}, PeerPort => $config{port} ) or print "Unable to connect: $!\n"; $sock->autoflush(1); print STDERR "Connected to $config{server}:$config{port}\n"; my $readers = IO::Select->new() or die "Can't create IO::Select read o +bject"; $readers->add($sock); $on = $TRUE; while ($on) { if(!defined $timeout) { $timeout = 0; } my @ready = $readers->can_read; for my $handle (@ready) { if($handle eq $sock) { $bytes = sysread($sock, $buffer, 4096); print "buffer: $buffer\n"; if($bytes > 0) { $botstats{bytes_rcvd} += $bytes; } while (defined ($line = <$sock>)) { $line =~ s/[\012\015]+$//; next unless $line; handle_input(\%active_channels, $line); timer(); } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: While? and IO::Socket
by steves (Curate) on Feb 15, 2003 at 09:17 UTC | |
|
Re: While? and IO::Socket
by so14k (Initiate) on Feb 15, 2003 at 06:12 UTC |