#!/usr/bin/perl
use IO::Socket;
my $sock = IO::Socket::INET->new(
LocalAddr => "localhost:9999",
ReuseAddr => 1,
Listen => SOMAXCONN,
) or die "couldn't create socket: $!\n";
while (1) {
my $client = $sock->accept();
while (my $line = <$client>) {
print $client join(" ",unpack("(H2)*", $line)), "\n";
}
close $client;
}
####
$ telnet localhost 9999
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
0d 0a
####
#!/usr/bin/perl -w
use strict;
use Net::Telnet;
my $t = Net::Telnet->new(Port => 9999);
$t->open("localhost");
$t->print;
my $r = $t->getline;
print $r;
####
$ ./890020_c.pl
0d 0a