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"
Il programma gira correttamente e si mette in ascolto sulla porta 6362codice:#!/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);
sul mio server netfirms faccio girare questo codice "client" eseguendolo da browser:
Mi aspettavo un messaggio tipo la data del giorno invece mi va in errore con questo messaggio: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);
"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!



Rispondi quotando