[newbie] IO::Socket::INET

L

Larry

Hello

I've a question about perl socket

I'm on MacOS9 running Macperl5.6,I'm connected to the internet via adsl
lan (dynamic ip)

Below the "server" code I've been working on:

Code:
#!/perl
#
# Server

use strict;
use warnings;
use IO::Socket::INET;

my $server = IO::Socket::INET->new(LocalPort => '6362',
Type      => SOCK_STREAM,
Reuse     => 1,
Listen    => 1 ) || die "$!\n";

while ( my $client = $server->accept() ) {

print $client "The time is now: " . scalar(localtime(time())) . "\n";
close $client;

}

close($server);

It does work fine!

Below the "Client" code I've uploaded on my netfirms host:

Code:
#!/perl
#
# Client

use strict;
use warnings;
use IO::Socket::INET;
use CGI::Carp "fatalsToBrowser";
use CGI;

my $q = new CGI();

print $q->header();

my $socket = IO::Socket::INET->new(PeerAddr => '80.116.244.30',
PeerPort => '6362',
Proto    => 'tcp') || die "Can't
connect to: 80.116.244.30 on port: 6362 $!\n";

print $socket "Hi server!\n";

my $answer = <$socket>;
print $answer;

close($socket);

Unfortunately when I run the script via browser I get this message: "no
route to host" ... I don't presently know why!
Far from it,when I run the code above on my Mac setting "PeerAddr" as
"127.0.0.1" it works quite fine! (I manage to get the "The time is..."
message from the "server" script!)

Anyone can help me?

ta
 
U

Uri Guttman

L> Unfortunately when I run the script via browser I get this message: "no
L> route to host" ... I don't presently know why!
L> Far from it,when I run the code above on my Mac setting "PeerAddr" as
L> "127.0.0.1" it works quite fine! (I manage to get the "The time is..."
L> message from the "server" script!)

that isn't a perl problem. you have no route to that host/port from
where you run the client. probably a firewall or something. maybe the
server box isn't exposed to the net or it has a firewall disallowing
incoming ports (i think osx has that). so check the network config stuff
for the mac first.

uri
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top