in reply to IO::Socket vs. Socket vs. off-the-shelf telnet
Is CRLF defined anywhere in your program? I can see that this is the source of trouble since you are chopping the EOL char and placing CRLF in its place. I tried this and it works as advertized:
Aziz,,,use IO::Socket; use constant CRLF => "\r\n";##### Add This my $quit = 0; my $port = 12345; my $socket = IO::Socket::INET->new( Listen => 20, LocalPort => $port, Timeout => 5, #60 * 60, Reuse => 1) or die "No socket: $!"; warn "listening on port $port...\n"; while ( !$quit ) { next unless my $session = $socket->accept; my $peer = gethostbyaddr($session->peeraddr,AF_INET) || $session->peerhost; my $port = $session->peerport; warn "Connection from [$peer,$port]\n"; while(<$session>) { #BLOCKS HERE $bytes{'in'} += length($_); chomp; my $msg_out = $_ . CRLF; $session->print($msg_out); print $msg_out; $bytes{'out'} += length($msg_out); } warn "Connection from [$peer,$port] finished\n"; close $session; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: IO::Socket vs. Socket vs. off-the-shelf telnet
by adamsj (Hermit) on Aug 13, 2001 at 00:13 UTC | |
by abstracts (Hermit) on Aug 13, 2001 at 00:36 UTC |