George Gallen on 26 Aug 2005 18:56:31 -0000

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[PLUG] RE: perl/socket question...

Title: RE: perl/socket question...

never mind.

I changed switched

while (defined(<$new_sock>)) {print $_;}
my $msg = "";
while (defined($msg = <$new_sock>)) {print $msg;}

and that works....Now I remember why I didn't like using $_ before....


     -----Original Message-----
    From:   George Gallen 
    Sent:   Friday, August 26, 2005 2:52 PM
    To:     ''
    Subject:        perl/socket question...

    OK. I'm starting to play with perl and sockets.

    I tried this extremely basic server/client

    use IO::Socket;
    my $sock = new IO::Socket::INET(LocalHost => '',LocalPort => '2064',Proto => 'tcp',Listen => 1, Reuse=> 1,);

    die "Could not create socket: $!\n" unless $sock;
    my $new_sock = $sock->accept();
    while (defined(<$new_sock>)) {print $_;}
    close ($sock)

    use IO::Socket;
    my $sock = new IO::Socket::INET(PeerAddr => '', PeerPort => '2064', Proto => 'tcp',);
    die "Could not create socket: $!\n" unless $sock;
    print $sock "Hello there!\n";

    I start up the server side, no errors, so far so good (it listens fine).
    I then (under another login), run the client side, also no errors, ends (as expected), and the server side ends also
      (as expected).

    HOWEVER... the "Hello there\n" isn't displayed on the server side.
    I also tried telnet to the port, and typing, and nothing that I type is displayed (on the server side).

    Any ideas?

    George Gallen
    Senior Programmer/Analyst
    Accounting/Data Division
    ph:856.848.1000 Ext 220

    SLACK Incorporated - Delivering the best in health care information and education worldwide.

Philadelphia Linux Users Group         --
Announcements -
General Discussion  --