Sto ancora smanettando sui socket ma poco ci ho capito:
Sto du MacOS9 con adsl lan (ip dinamico) e con Macperl eseguo questo codice "server"
codice:
#!/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);
Il programma gira correttamente e si mette in ascolto sulla porta 6362
sul mio server netfirms faccio girare questo codice "client" eseguendolo da browser:
codice:
#!/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);
Mi aspettavo un messaggio tipo la data del giorno invece mi va in errore con questo messaggio:
"no route to host"
perche?
(al contrario quando faccio la prova con il client in locale "127.0.0.1" va tutto alla perfezione)
Qualche suggerimento?
Grazie!