| [reply] |
To get the server's response, recv.
The Perl Cookbook has good examples of using sockets.
| [reply] |
As a side note, why is the recv() subroutine set up so strangely? Passing the variable that will hold what the function returns reminds me of PHP and its "forced references". Wouldn't this code be much more intuitive and Perlish?
$reponse = $socket->recv($length, $flags);
And for that matter, how is this even done? I would think you'd at least need the name of the variable to set it from another package. Isn't passing an uninitialized variable the same as passing an empty string? I'm all confused, perhaps someone could explain what I think are the relevant bits of recv() in IO::Socket:
my $sock = $_[0];
${*$sock}{'io_socket_peername'} = recv($sock, $_[1]='', $len, $flags);
| [reply] [d/l] [select] |
| [reply] |
Hi,
Please check this link
Update:-
Since IO::Socket which is explained clearly and more in detail here in the above mentioned link i have used pm search and gave resultant page here. I think this will give u some idea to solve ur issues.
-prasanna.k | [reply] |
Thanks for all the great links, here's the code I have now, as a very basic example to anyone who might find this thread:
use IO::Socket::INET;
my $socket = IO::Socket::INET->new(
'PeerAddr' => '192.168.1.100',
'PeerPort' => 29900,
'Proto' => 'udp',
'Timeout' => 15
);
$socket->autoflush(1);
$socket->send($query);
$socket->recv(my $response, 1024 * 5);
print $response;
The only thing I'm worried about is that the first time I tried this, I was downloading something and the script just hung without returning anything. This is going to be going on a shared server, so I'm worried about hogging resources. Is there any way to guarantee that the script won't wait too long for the information? | [reply] [d/l] |