i'm writing some client code at work to talk to a udp server we use for debugging. the server sends out the following c structure:
typedef struct Net_LogMsgHdr {
int32 magic;
Net_LogMsgType type;
int32 nextLogChar;
int32 logBufferSize;
int32 length;
int32 override;
uint64 bootTS;
uint64 pad;
} Net_LogMsgHdr;
i've got something like this set up on the client side:
my $sock = IO::Socket::INET->new(
LocalAddr => '127.0.0.1:6300',
LocalPort => 6300,
Proto => 'udp',
);
my $incoming;
while ($sock->recv($incoming, 65536)) {
my ($magic, $type, $nextLogChar, $logBufferSize, $length, $override
+, $bootTS, $pad) = unpack "llllllQQ" , $incoming;
which in theory should work, except my perl doesn't grok 64 bit integers. i know i can compile a version that does, but that's not a solution, since this has to be portable amongst our development machines here. i thought about bitshifting, but the camel book has the following warning:
"Results on large (or negative) numbers may vary depending on the numb
+er of bits your machine uses to represent integers".
My machine (of course) uses 32 bit integers. So there's no way that i know of to go from a 128bit chunk of network data to two 64bit uints (excluding unpack).
any ideas? cpan modules? *shudder* regexes?
BlueLines
Disclaimer:
This post may contain inaccurate information, be habit forming, cause atomic warfare between peaceful countries, speed up male pattern baldness, interfere with your cable reception, exile you from certain third world countries, ruin your marriage, and generally spoil your day. No batteries included, no strings attached, your mileage may vary.