Click to See Complete Forum and Search --> : perl communicating scripts
how do two perl scripts,running on two different
machines(both connected through a network with ip's
assigned to them) communicate to each other?
i mean how can they send messages back and forth
in an easy manner ?
ok so i'm trying to use this script to do communication through
sockets
i started making the client but for unknown reasons a socket connection cannot
be opened
heres my code
use IO::Socket;
$host='89.37.70.170';
$port='7070';
$proto='tcp';
$listen=1;$reuse=1;
my $sock_conn=new IO::Socket::INET
(
LocalHost => $host,
LocalPort => $port,
Proto => $proto,
Listen => $listen,
Reuse => $reuse
);
die "cannot create socket $!\n" unless $sock;
my $socket=$sock_conn->accept();
while(<$socket>){
print $_;
};
close($socket);
bwkaz
01-06-2007, 10:40 AM
This line:
die "cannot create socket $!\n" unless $sock; needs to read like this:
die "cannot create socket $!\n" unless $sock_conn; Since you called your master-socket variable $sock_conn, you won't be able to refer to it under the name $sock here. ;)
(This is why "use strict;" is always good in Perl: it would have given you an error about an "undeclared identifier $sock" instead of silently creating the variable and then running the die statement because its value wasn't set.)
wow thanks bwkaz
that was very nice ! :)