Configures the byte order used by methods that send and receive various data types, or arrays of types. Byte swapping will occur in the individual values, if necessary, to achieve the desired byte ordering in order to account for endian differences between the client and server.

Namespace:  Quanser.Communications
Assembly:  Quanser.Communications (in Quanser.Communications.dll)

Syntax

Visual Basic (Declaration)
Public Sub SetByteOrder ( _
	byteOrder As Stream..::.ByteOrder _
)
C#
public void SetByteOrder(
	Stream..::.ByteOrder byteOrder
)
Visual C++
public:
void SetByteOrder(
	Stream..::.ByteOrder byteOrder
)
JavaScript
function setByteOrder(byteOrder);

Parameters

byteOrder
Type: Quanser.Communications..::.Stream..::.ByteOrder
The byte order to use when sending and receiving data over the stream.

Remarks

This method may be used to cause the bytes within shorts, integers, doubles and other data types to be swapped by the Stream object to account for endian differences between the two endpoints of the connection. The Stream object does not detect the endianness of the peer.

Calling this method with the byteOrder argument set to ByteOrder.LittleEndian causes the bytes to be swapped if the underlying platform is big endian. If the underlying platform is little endian then the bytes are not swapped.

Calling this method with the byteOrder argument set to ByteOrder.BigEndian causes the bytes to be swapped if the underlying platform is little endian. If the underlying platform is big endian then the bytes are not swapped.

Calling this method with the byteOrder argument set to ByteOrder.NativeEndian indicates that the bytes should not be swapped and the byte order of the underlying platform will be used. This byte order is the default.

Byte swapping is only necessary when communicating between processors that use a different endianness. 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 (NativeEndian byte order).

Note that the SetSwapBytes(Boolean) and SetByteOrder(Stream..::.ByteOrder) methods override each other, so byte swapping will be determined by the last method called.

Examples

This example configures the stream to use little endian (Intel) byte ordering.
C# Copy Code
stream.SetByteOrder(Stream.ByteOrder.LittleEndian);
Visual Basic Copy Code
stream.SetByteOrder(Stream.ByteOrder.LittleEndian)
Visual C++ Copy Code
stream->SetByteOrder(Stream::ByteOrder::LittleEndian);

Exceptions

ExceptionCondition
Quanser.Communications..::.StreamException If the byte order cannot be configured then an exception is thrown. This situation should never occur unless the underlying stream has been closed.

See Also