Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I posted this to comp.lang.perl.misc and have gotten nada thus far. Maybe some monkly advice can shine down on me...
What I need to do: send data over a network in network-byte order (big endian) in 4 byte chunks (XDR data format description, RFC 1832). Integers are 4 bytes long, strings of variable size are preceded by an int (4 bytes) which gives the real data length and then null padded to be a multiple of 4 bytes long (sorta pascal-esque), etc. A byte is defined as 8 bits.
Two problems (at least) I've found thinking through this:
This is perl-to-perl over the net for now but will need to be perl-to-C very soon.
Also wondering, can length, substr, join, // and other various perl string functions be used to look at/modify packed data/bytes safely? Any pitfalls here?
Lastly is there documentation on pack/unpack anywhere that describes in more detail than the Camel book (specificly I'd love to see a lot a lot of commented examples). pack/unpack has always been a time sink for me when I've needed to use it.
thanks,
Micah
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to use pack/unpack data over a network
by repson (Chaplain) on Jan 05, 2001 at 16:18 UTC | |
by Fastolfe (Vicar) on Jan 05, 2001 at 19:45 UTC | |
|
Re: How to use pack/unpack data over a network
by chipmunk (Parson) on Jan 05, 2001 at 20:02 UTC |