Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > [newbie] IO::Socket::INET

Reply
Thread Tools

[newbie] IO::Socket::INET

 
 
Larry
Guest
Posts: n/a
 
      12-01-2004
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
 
Reply With Quote
 
 
 
 
Uri Guttman
Guest
Posts: n/a
 
      12-01-2004
>>>>> "L" == Larry <> writes:

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

--
Uri Guttman ------ -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57