> -----Original Message-----
> From: walter valenti [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 30, 2002 11:11 AM
> To: [EMAIL PROTECTED]
> Subject: socket
>
>
> Hola,
>
> qualcuno sa dirmi perch�:
(Using translator.dictionary.com, I see that the question is why the first
example "work" but the second blocks on the read, because the GET isn't
being
transmitted to the server.)
>
> #!/usr/bin/perl
>
> use IO::Socket;
> #use diagnostics;
> my $host=$ARGV[0];
> if(!$host){
> die"...host???\n";
> }
> $|=1;
>
> $socket=IO::Socket::INET->new(PeerAddr =>$host, PeerPort=>80,
> Proto=>"TCP") || die"$!\n";
> print $socket "GET / HTTP/1.0\r\n\r\n";
> while(<$socket>){
> print"$_\n";
> }
> close($socket);
>
>
> FUNZIONA (scrivi e leggo dal socket),mentre al contrario:
>
> #!/usr/bin/perl
>
> use Socket;
> #use diagnostics;
> my $host=$ARGV[0];
> if(!$host){
> die"...host???\n";
> }
> $|=1;
This line sets only current filehandle (STDOUT) to autoflush. It doesn't
affect your socket. The example with IO::Socket::INET works because
IO::Socket::new() calls autoflush(1) on the socket.
perldoc -f select
perldoc -m IO::Socket (look at sub new)
>
> socket(SO,PF_INET,SOCK_STREAM,getprotobyname('tcp')) || die"$!\n";
>
> my $dest=sockaddr_in(80,inet_aton($host));
> connect(SO,$dest) || die"$!\n";
You need something like:
use IO::Handle;
SO->autoflush(1);
> print SO "GET / HTTP/1.0\r\n\r\n";
> while(<SO>){
> print"$_\n";
> }
>
> NON FUNZIONA...
> ovvero per qualche oscuro motivo la lettura dal socket
> (<SO>), blocca la
> scrittura sul socket (print SO).
> Se invece non cerco di leggere dal socket (cio� non c'� <SO>) la
> scrittura va a buon fine.
> (Il tutto controverificato con uno sniffer).
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]