socket error

J

jis

use IO::Socket;

my $sock = new IO::Socket::INET (
PeerAddr => '144.xxx.31.142',
PeerPort => '9000',
Proto => 'tcp',
);
die "Could not create socket: $!\n" unless $sock;
print $sock "Hello Andy!\n";
close($sock);

The ip address belongs to a another system in the netrwork.

But i get an error "Could not create socket: Unknown error"

If i give my ip address if my own system i do not have any problems..
Is it because firewall stops me or ....

Pls help.

Cheers,
Jis
 
X

xhoster

jis said:
use IO::Socket;

my $sock = new IO::Socket::INET (
PeerAddr => '144.xxx.31.142',
PeerPort => '9000',
Proto => 'tcp',
);
die "Could not create socket: $!\n" unless $sock;
print $sock "Hello Andy!\n";
close($sock);

The ip address belongs to a another system in the netrwork.

But i get an error "Could not create socket: Unknown error"

Try looking in $@ instead of or in addition to $!

Xho
 
D

Dr.Ruud

jis schreef:
my $sock = new IO::Socket::INET (
PeerAddr => '144.xxx.31.142',
PeerPort => '9000',
Proto => 'tcp',
);
die "Could not create socket: $!\n" unless $sock;

It is easy to combine that:

my $sock = IO::Socket::INET->new(
PeerAddr => '144.xxx.31.142',
PeerPort => '9000',
Proto => 'tcp',
) or die "Could not create socket: ($!) ($@)\n";
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top