----- Original Message ----- 
From: "Groleo Marius" <[EMAIL PROTECTED]>
To: <beginners@perl.org>
Sent: Thursday, January 13, 2005 4:46 AM
Subject: Perl Socket


> Hi list!
Hello Marius,
>
> im try-ing this code, to get a multi line server response:
>
> use Socket;
> socket(sock, AF_INET, SOCK_STREAM, getprotobyname('tcp')) || die "error:
$!\n";
>     $dest = sockaddr_in($_[0], inet_aton($_[1]));
>     connect(sock, $dest) || die "error: $!\n";
>     select(sock);
>
> while ($response=<sock>) {
>   print;
> }
> close (sock) || die "close: $!\n";
>
> The thing is that after it gets the whole response, the script hangs,

That is because you are looping on a read and once you client sends all of
it's data on soket, the server block's on next read. You should build
sometype of a controll scheme into your script.


> and i have to quit using Ctrl+c.
>
> Question:
> How can i get the whole server response, that is a multi-lined
> response, and to get the script not to hang??
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to