next up previous contents index
Next: Operation Up: Server Mode Previous: The Ascii Format   Contents   Index


The Binary Format

This format is used if the binary command is in effect. It is somewhat more efficient and easier to parse. Numeric data are sent in ``network byte order'' which means that the MSB arrives first. Integers are always 32-bits, other numeric data are 64-bit IEEE floating point values.

The possible return values are listed in the table below. These correspond directly to the ASCII returns described in the previous section. The first 4-byte field indicates the type of return. If the longform mode is in effect, the data are returned in the format shown below, otherwise there is no further content.

ok (integer 0)  
in block (integer 1)  
error (integer 2)  
scalar (integer 3) (double value)
string (integer 4) (integer length) (length-byte string)
array (integer 5) (integer size) (size 8-byte values)
zlist (integer 6) (integer num) (num*6 4-byte integers)
lexpr (integer 7) (integer length) (length-byte string)
handle (integer 8) (integer id)

The first three responses correspond to the ``ok'', ``in block'' and ``error'' return prompts, respectively. The last six responses correspond to data types. For scalar data, a double precision (8-byte) data item follows. For strings, arrays, zlists and lexprs, a size integer follows, followed by the data. For strings, the size includes the null-byte string termination. For arrays, the size is the number of double precision values (8 bytes each) that follow. For trapezoid lists, te size is the number of six-integer trapezoid fields that follow. The handle return is a single integer giving the internal id.

The raw bytes read for a numeric value must be converted to the machine's byte order before being processed in a program. For integers, the ntohl C library function is usually available. For floating values, an example conversion routine is provided in the xclient.cc file. The byte order is the same as that used by Sun sparc systems, thus this issue can be ignored on those systems, unless code portability is desired.


next up previous contents index
Next: Operation Up: Server Mode Previous: The Ascii Format   Contents   Index
Stephen R. Whiteley 2006-10-23