note
scorpio17
<p>
Thanks again. I've never taken the time to learn how pack and unpack work as well as I should, and it looks like that mistake has finally caught up with me.
<p>
For what it's worth - the original C++ code (which I didn't write) used the functions htonl() and ntohl(). I was not familiar with those, but could tell that it had something to do with encoding/decoding data, so I googled for a perl implementation, and found one in the [mod://Net::Inet] module on CPAN. It's written to take an array of inputs, but I knew that in my case I'd only be sending in a single argument.
<p>
As it turns out, my code did have another error: recv() returns undef if there's an error, so I had to change this:
<code>
# this is broken !!!
$socket->recv($data, $reponse_length) or die "Couldn't read data from server: $!";
</code>
<p>into this:
<code>
unless (defined $socket->recv($data, $reponse_length)) {
die "Couldn't read data from server: $!";
}
</code>
<p>
But everything seems to be working now -thank you!!
986570
986594