public class NetworkBinaryWriter

Summary

Subclass of BinaryWriter that writes integers etc in correct network order.

Remarks

Kludge to compensate for .NET's broken little-endian-only BinaryWriter.

See also NetworkBinaryReader.

Constructor Summary

Flags Name Summary
public NetworkBinaryWriter(Stream output, Encoding encoding)

Construct a NetworkBinaryWriter over the given input stream, reading strings using the given encoding.

public NetworkBinaryWriter(Stream output)

Construct a NetworkBinaryWriter over the given input stream.

Method Summary

Flags Name Summary
public static BinaryWriter TemporaryBinaryWriter(int initialSize)

Helper method for constructing a temporary BinaryWriter streaming into a fresh MemoryStream provisioned with the given initialSize.

public static byte[] TemporaryContents(BinaryWriter w)

Helper method for extracting the byte[] contents of a BinaryWriter over a MemoryStream, such as constructed by TemporaryBinaryWriter.

public virtual void Write(single f)

Override BinaryWriter's method for network-order.

public virtual void Write(double d)

Override BinaryWriter's method for network-order.

public virtual void Write(short i)

Override BinaryWriter's method for network-order.

public virtual void Write(ulong i)

Override BinaryWriter's method for network-order.

public virtual void Write(int i)

Override BinaryWriter's method for network-order.

public virtual void Write(ushort i)

Override BinaryWriter's method for network-order.

public virtual void Write(long i)

Override BinaryWriter's method for network-order.

public virtual void Write(uint i)

Override BinaryWriter's method for network-order.

Constructor Detail

NetworkBinaryWriter

public NetworkBinaryWriter(Stream output, Encoding encoding)

Parameters
Name Type
output Stream
encoding Encoding

Summary

Construct a NetworkBinaryWriter over the given input stream, reading strings using the given encoding.

NetworkBinaryWriter

public NetworkBinaryWriter(Stream output)

Parameters
Name Type
output Stream

Summary

Construct a NetworkBinaryWriter over the given input stream.

Method Detail

TemporaryBinaryWriter

public static BinaryWriter TemporaryBinaryWriter(int initialSize)

Flags public static
Return type BinaryWriter
Parameters
Name Type
initialSize int

Summary

Helper method for constructing a temporary BinaryWriter streaming into a fresh MemoryStream provisioned with the given initialSize.

TemporaryContents

public static byte[] TemporaryContents(BinaryWriter w)

Flags public static
Return type byte[]
Parameters
Name Type
w BinaryWriter

Summary

Helper method for extracting the byte[] contents of a BinaryWriter over a MemoryStream, such as constructed by TemporaryBinaryWriter.

Write

public virtual void Write(single f)

Flags public virtual
Return type void
Parameters
Name Type
f single

Summary

Override BinaryWriter's method for network-order.

Write

public virtual void Write(double d)

Flags public virtual
Return type void
Parameters
Name Type
d double

Summary

Override BinaryWriter's method for network-order.

Write

public virtual void Write(short i)

Flags public virtual
Return type void
Parameters
Name Type
i short

Summary

Override BinaryWriter's method for network-order.

Write

public virtual void Write(ulong i)

Flags public virtual
Return type void
Parameters
Name Type
i ulong

Summary

Override BinaryWriter's method for network-order.

Write

public virtual void Write(int i)

Flags public virtual
Return type void
Parameters
Name Type
i int

Summary

Override BinaryWriter's method for network-order.

Write

public virtual void Write(ushort i)

Flags public virtual
Return type void
Parameters
Name Type
i ushort

Summary

Override BinaryWriter's method for network-order.

Write

public virtual void Write(long i)

Flags public virtual
Return type void
Parameters
Name Type
i long

Summary

Override BinaryWriter's method for network-order.

Write

public virtual void Write(uint i)

Flags public virtual
Return type void
Parameters
Name Type
i uint

Summary

Override BinaryWriter's method for network-order.