stream_poll stream_set_character_format navigation bar

Table of Contents

stream_set_byte_order

Configures the byte order used by the stream for multi-byte data types.

Syntax

stream_set_byte_order(stream, byte_order) % Use specified byte order
stream_set_byte_order(stream)             % Use native byte order (no byte swapping)
    

Description

Determines whether the functions that send and receive int16's, int32's, int64's, floats or doubles, or arrays of them, swap the bytes in the individual values. Byte swapping is performed when the given byte_order does not match the native byte order of the underlying platform.

For example, Intel processors are little endian (LSB first) while Motorola processors tend to be big endian (MSB first). By default, no byte swapping takes place.

If the byte_order is set to 0 (native endian) or omitted then the native byte order of the underlying platform is used and no byte swapping takes place. Native endian is the default byte order.

If the byte_order is set to 1 (little endian) and the underlying platform is little endian then no byte swapping takes place. However, if the underlying platform is big endian, then byte swapping is performed on all multi-byte data types sent or received over the stream.

If the byte_order is set to 2 (big endian) and the underlying platform is big endian then no byte swapping takes place. However, if the underlying platform is little endian, then byte swapping is performed on all multi-byte data types sent or received over the stream.

Note that stream_set_byte_order and stream_set_swap_bytes override each other, so byte swapping is performed according to the last function called.

This operation is not valid on listening streams created using stream_listen.

Parameters

stream

Stream handle returned by stream_connect or stream_accept.

byte_order

The desired byte order for multi-byte data types. Valid byte orders are:

Value

Meaning

0

Native byte order (no byte swapping performed)

1

Little endian byte order (byte swapping performed if platform is big endian)

2

Big endian byte order (byte swapping performed if platform is little endian)

If this argument is not specified it defaults to 0 (native endian byte order).

Outputs

This function has no outputs.

Examples

stream_set_byte_order(stream, 1); % Use little endian byte order for this stream
    

See Also

 

navigation bar