in reply to Working with C structures over network
Depending on the kind of data you have available and the number of structures, C compilers and records you have to wrap, there are two approaches:
The simple approach is to use the pack and unpack functions, which pack an array into a string and back.
Your example struct would likely be packed as:
pack "lCvsif", $var1, $var2, $var3, $var4, $var5, $var6;
With the caveat that floating point structures are only valid for passing around on the same architecture, as there is no standard.
The hard, but potentially more rewarding approach is Convert::Binary::C, which takes a C struct definition and a C compiler, and packs an array into a string that looks as if the C compiler did it. This most likely is overkill.
|
|---|