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.

In reply to pack() and non-64bit systems by BlueLines

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.