Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > funky TCP problems

Reply
Thread Tools

funky TCP problems

 
 
grocery_stocker
Guest
Posts: n/a
 
      07-22-2007
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?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
send tcp raw socket (bogus tcp header length) Tiger C Programming 5 05-01-2006 05:53 AM
tcp/ip vs microsoft tcp/ip ver 6 john Computer Support 1 08-05-2005 02:45 PM
NAT two outside TCP ports to one inside TCP port Kevin Cisco 1 11-10-2004 08:15 AM
Secure and compressed TCP/IP connection (for any TCP/IP services and applications) Pavel Aronovich Computer Security 0 02-22-2004 08:35 AM
LPR/Standard, TCP/IP, HP TCP/IP Ports DJ Chiro MCSE 1 11-07-2003 08:06 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57