Vanilla List Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Binary portability



Doug aka Subby is having trouble viewing Cambot recordings on Windows,
and I suspect that the problem may be that the cambot files are not
portable across platforms.  I don't run Windows at home so I can't
debug it.

The code to write and read cambot files just dumps the C struct of the
packet out/in, so I don't see how this would be portable.  But
wouldn't there also be the same problem with network communication?
How can Windows clients and the Unix server communicate?

Below is the question from the C faq that talks about binary
portability.

-Jeff

http://www.eskimo.com/~scs/C-faq/q20.5.html

How can I write data files which can be read on other machines with
different word size, byte order, or floating point formats?

The most portable solution is to use text files (usually ASCII),
written with fprintf and read with fscanf or the like. (Similar advice
also applies to network protocols.) Be skeptical of arguments which
imply that text files are too big, or that reading and writing them is
too slow. Not only is their efficiency frequently acceptable in
practice, but the advantages of being able to interchange them easily
between machines, and manipulate them with standard tools, can be
overwhelming.

If you must use a binary format, you can improve portability, and
perhaps take advantage of prewritten I/O libraries, by making use of
standardized formats such as Sun's XDR (RFC 1014), OSI's ASN.1
(referenced in CCITT X.409 and ISO 8825 ``Basic Encoding Rules''),
CDF, netCDF, or HDF. See also questions 2.12 and 12.38.