funky TCP problems

G

grocery_stocker

Given the following
#!/usr/bin/perl -w
use IO::Socket;

my($handle, $line, $kidpid);
$handle = IO::Socket::INET->new(
PeerAddr =>"137.104.128.2",
PeerPort =>"23",
Proto=>"tcp",
)
or die "cant connect to port: $!";

$handle->autoflush(1);
print STDERR "[Connected]\n";
die "can't fork: $!" unless defined($kidpid = fork());

if($kidpid) {
while(defined($line = <$handle>)){
print STDOUT $line;
}
kill("TERM", $kidpid);
}

else {
while(defined ($line = <STDIN>)){
print $handle $line;
}
}

When I run it, I get
[cdalten@localhost]$ ./foo.pl
[Connected]

now, when I hit the 'enter' key on my keyboard, I get
?????


University of Wisconsin - Platteville (pine.ucs.uwplatt.edu)

Then after a few seconds, I get
Username:
Error reading command input


However, what I really want to see is
Trying 137.104.128.2...
Connected to uwplatt.edu (137.104.128.2).
Escape character is '^]'.



University of Wisconsin - Platteville (pine.ucs.uwplatt.edu)

Username:



What's my error in logic?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top