funky TCP problems

Discussion in 'Perl Misc' started by grocery_stocker, Jul 23, 2007.

  1. 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?
    grocery_stocker, Jul 23, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Diogenes Dilone

    Funky error Situation

    Diogenes Dilone, Jan 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    514
    Diogenes Dilone
    Jan 7, 2004
  2. =?Utf-8?B?VHJhY3k=?=

    Funky address change.

    =?Utf-8?B?VHJhY3k=?=, Mar 16, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    361
    Juan T. Llibre
    Mar 16, 2006
  3. iksrazal

    funky but simple regex

    iksrazal, Jul 19, 2004, in forum: Java
    Replies:
    3
    Views:
    368
    iksrazal
    Jul 20, 2004
  4. dwilson
    Replies:
    0
    Views:
    1,197
    dwilson
    Apr 8, 2005
  5. Tiger
    Replies:
    5
    Views:
    952
    Dave Thompson
    May 1, 2006
Loading...

Share This Page