Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: XDR basic encode decode

by andal (Hermit)
on Mar 27, 2012 at 07:34 UTC ( #961865=note: print w/replies, xml ) Need Help??

in reply to XDR basic encode decode

Perl's pack() and unpack() offer partial solutions: the "N" format delivers a good fit (4 byte uint in network byte-order), but "A/*" encodes a string without extending the byte string payload length up to a multiple of 4-bytes.

Have you tried something like

my $l = length($string); $l += 3; $l >>= 2; $l <<= 2; pack("a$l", $string);

Replies are listed 'Best First'.
Re^2: XDR basic encode decode
by mr0 (Initiate) on Mar 27, 2012 at 09:20 UTC

    Yeah, I'd do something like that in a routine - probably called xdr_put_str() I'm after finding whether anyone has already written wrappers like this. Thanks.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://961865]
[LanX]: should be even easier for you
[Discipulus]: oh well we cant afford two monks fired in a day!
[LanX]: any news from tye ' s search?
[MidLifeXis]: Ugh - who else?
[Discipulus]: so the right term is 'gired'
[Discipulus]: look at ot by karl
Discipulus gired: adj the work position that stands between hired and fired..
LanX recommends inner immigration, work less hard and enjoy pay roll
[MidLifeXis]: ahh, yeah, didn't look through nodes yet today.
[erix]: haha

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (14)
As of 2017-03-23 12:46 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (286 votes). Check out past polls.