Hi,
I found this simple example of sockets in a tutorial and
I want to make it work. It seems to work, but I get no output
at the receive end. The problem seems to revolve around
the receiver's "print $_" statement.
I run RECEIVE first, and it starts with no errors and waits.
Then I run SEND and it runs without error and exits.
The RECEIVE console then reports the error:
"Use of uninitialized value in print at receive.pl line 15 <GEN1>
line1".

I have tried many guesses at changing $_ which I won't dignify
by reporting them here. The best I could do was get various
printouts like SCALAR(Ox123bc345) instead of my message.

Anyone know what's wrong with that print statement?


###########RECEIVE:################
#!/usr/bin/perl -w
use IO::Socket;
my $sock = new IO::Socket::INET (
      LocalHost => 'localhost',
      LocalPort => '7070',
      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);
 
#########SEND########################
#/usr/bin/perl -w
use IO::Socket;
my $sock = new IO::Socket::INET (
            PeerAddr => 'localhost',
            PeerPort => '7070',
               Proto => 'tcp',
                      );
die "Could not create socket: $!\n" unless $sock;
print $sock "Hello there!\n";
close($sock);


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to