reckfellENGINE

StreamPeer

Base byte-stream API and typed binary input/output.

On this page
class StreamPeerReckfellSharpInherits RefCounted

StreamPeer is abstract. Use StreamPeerBuffer for memory data and a supported transport for networking. Streams do not automatically create message boundaries: agree on format, lengths, byte order and partial-operation handling.

GetData/GetPartialData return Error and bytes; PutPartialData returns Error and sent count. Numeric getters/setters and string shortcuts do not provide that separate status. A returned number is not proof of a successful read; collect and verify a complete field first.

BigEndian changes subsequent numeric operations, not bytes of an existing array. UTF-8 lengths count bytes rather than C# string.Length. Impose protocol limits on externally supplied lengths.

See StreamPeerBuffer for a complete checked-message example.

Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.

Properties1

BigEndianProperty
# BigEndian
C#
public bool BigEndian { get; set; }

Byte order for subsequent numeric operations and length prefixes. Defaults to false for little-endian; true selects big-endian. Changing it does not reorder existing bytes or raw PutData arrays.

Methods37

Get16short
# Get16
C#
public short Get16();

Reads 2 bytes as signed 16-bit. Widths greater than one byte follow BigEndian. Returns no Error: ensure a complete field beforehand; a short/failed read does not yield a trustworthy number.

Returns short

Read value of C# type short. Not an Error/value pair; the value does not establish read success.

Get32int
# Get32
C#
public int Get32();

Reads 4 bytes as signed 32-bit. Widths greater than one byte follow BigEndian. Returns no Error: ensure a complete field beforehand; a short/failed read does not yield a trustworthy number.

Returns int

Read value of C# type int. Not an Error/value pair; the value does not establish read success.

Get64long
# Get64
C#
public long Get64();

Reads 8 bytes as signed 64-bit. Widths greater than one byte follow BigEndian. Returns no Error: ensure a complete field beforehand; a short/failed read does not yield a trustworthy number.

Returns long

Read value of C# type long. Not an Error/value pair; the value does not establish read success.

Get8sbyte
# Get8
C#
public sbyte Get8();

Reads 1 byte as signed 8-bit. Widths greater than one byte follow BigEndian. Returns no Error: ensure a complete field beforehand; a short/failed read does not yield a trustworthy number.

Returns sbyte

Read value of C# type sbyte. Not an Error/value pair; the value does not establish read success.

GetAvailableBytesint
# GetAvailableBytes
C#
public int GetAvailableBytes();

Returns readable-byte availability for the implementation. Not the next message size or a guarantee of a complete field/packet. For StreamPeerBuffer this is GetSize()-GetPosition().

Returns int

Available byte count. StreamPeerBuffer can return a negative value after Resize leaves its cursor beyond the end; repair position first.

GetDataReckfell.Collections.Array
# GetData
C#
public Reckfell.Collections.Array GetData(int bytes);

Attempts to read the requested byte count and returns [Error, byte[]]. Check Error before using data. Socket streams can wait for missing bytes; a short StreamPeerBuffer read reports failure after already consuming the available portion.

Parameters
NameTypeDefault
bytesint—
bytes

Nonnegative byte count to read. Check your protocol’s upper limit before calling.

Returns Reckfell.Collections.Array

Two-Variant Array: [Error code, packed bytes]. Extract byte[] in C# after checking the code. On failure, do not assume complete or safely initialized contents.

GetDoubledouble
# GetDouble
C#
public double GetDouble();

Reads 8 bytes as binary64. Widths greater than one byte follow BigEndian. Returns no Error: ensure a complete field beforehand; a short/failed read does not yield a trustworthy number.

Returns double

Read value of C# type double. Not an Error/value pair; the value does not establish read success.

GetFloatfloat
# GetFloat
C#
public float GetFloat();

Reads 4 bytes as binary32. Widths greater than one byte follow BigEndian. Returns no Error: ensure a complete field beforehand; a short/failed read does not yield a trustworthy number.

Returns float

Read value of C# type float. Not an Error/value pair; the value does not establish read success.

GetHalffloat
# GetHalf
C#
public float GetHalf();

Reads 2 bytes as binary16. Widths greater than one byte follow BigEndian. Returns no Error: ensure a complete field beforehand; a short/failed read does not yield a trustworthy number. binary16 has less precision/range than C# float.

Returns float

Read value of C# type float. Not an Error/value pair; the value does not establish read success.

GetPartialDataReckfell.Collections.Array
# GetPartialData
C#
public Reckfell.Collections.Array GetPartialData(int bytes);

Reads up to the requested byte count without requiring all bytes in this call. Returns [Error, byte[]]; on success the array length is the actual received count. Accumulate incomplete messages in your own buffer.

Parameters
NameTypeDefault
bytesint—
bytes

Nonnegative byte count to read. Check your protocol’s upper limit before calling.

Returns Reckfell.Collections.Array

Array [Error code, packed bytes]. On Error.Ok the array length is the actual read count; on failure the array is empty.

GetStringstring
# GetString
C#
public string GetString(int bytes = -1);

Reads the plain string format paired with PutString. bytes<0 reads a 32-bit length prefix first; otherwise reads the exact byte count without a prefix. Use the UTF-8 pair for Unicode. Bound externally supplied lengths before allocation.

Parameters
NameTypeDefault
bytesint-1
bytes

String byte count. A negative value reads a 32-bit length prefix; a nonnegative value reads exactly that many bytes without a prefix.

Returns string

Resulting string. Empty text alone does not distinguish empty content from read failure.

GetU16ushort
# GetU16
C#
public ushort GetU16();

Reads 2 bytes as unsigned 16-bit. Widths greater than one byte follow BigEndian. Returns no Error: ensure a complete field beforehand; a short/failed read does not yield a trustworthy number.

Returns ushort

Read value of C# type ushort. Not an Error/value pair; the value does not establish read success.

GetU32uint
# GetU32
C#
public uint GetU32();

Reads 4 bytes as unsigned 32-bit. Widths greater than one byte follow BigEndian. Returns no Error: ensure a complete field beforehand; a short/failed read does not yield a trustworthy number.

Returns uint

Read value of C# type uint. Not an Error/value pair; the value does not establish read success.

GetU64ulong
# GetU64
C#
public ulong GetU64();

Reads 8 bytes as unsigned 64-bit. Widths greater than one byte follow BigEndian. Returns no Error: ensure a complete field beforehand; a short/failed read does not yield a trustworthy number.

Returns ulong

Read value of C# type ulong. Not an Error/value pair; the value does not establish read success.

GetU8byte
# GetU8
C#
public byte GetU8();

Reads 1 byte as unsigned 8-bit. Widths greater than one byte follow BigEndian. Returns no Error: ensure a complete field beforehand; a short/failed read does not yield a trustworthy number.

Returns byte

Read value of C# type byte. Not an Error/value pair; the value does not establish read success.

GetUtf8Stringstring
# GetUtf8String
C#
public string GetUtf8String(int bytes = -1);

Reads UTF-8 text. bytes<0 consumes its own 32-bit prefix; a supplied count reads those bytes only. Do not pass a C# character count. No separate Error is returned; explicitly control lengths/decoding for strict external formats.

Parameters
NameTypeDefault
bytesint-1
bytes

String byte count. A negative value reads a 32-bit length prefix; a nonnegative value reads exactly that many bytes without a prefix.

Returns string

Resulting string. Empty text alone does not distinguish empty content from read failure.

GetVarVariant
# GetVar
C#
public Variant GetVar(bool allowObjects = false);

Reads a length-prefixed binary Variant produced by PutVar. Not JSON. Check input trust, size and expected type; the method does not impose an application packet-size limit or return a separate Error.

Parameters
NameTypeDefault
allowObjectsboolfalse
allowObjects

Defaults to false. true permits object reconstruction during decoding; do not enable for untrusted content. Not schema validation or a sandbox.

Returns Variant

Decoded Variant; Nil can be valid data or a failure result with diagnostics.

IsBigEndianEnabledbool
# IsBigEndianEnabled
C#
public bool IsBigEndianEnabled();

Returns the same flag as BigEndian; does not detect the byte order of loaded data.

Returns bool

Current BigEndian setting; false means little-endian.

Put16void
# Put16
C#
public void Put16(short value);

Writes 2 bytes as signed 16-bit. Widths greater than one byte follow BigEndian. Returns no Error; use explicit raw-write result checks for fallible transports.

Parameters
NameTypeDefault
valueshort—
value

Value for signed 16-bit, 2 bytes. Agree on the same format with the reader; a numeric type alone does not define message schema.

Put32void
# Put32
C#
public void Put32(int value);

Writes 4 bytes as signed 32-bit. Widths greater than one byte follow BigEndian. Returns no Error; use explicit raw-write result checks for fallible transports.

Parameters
NameTypeDefault
valueint—
value

Value for signed 32-bit, 4 bytes. Agree on the same format with the reader; a numeric type alone does not define message schema.

Put64void
# Put64
C#
public void Put64(long value);

Writes 8 bytes as signed 64-bit. Widths greater than one byte follow BigEndian. Returns no Error; use explicit raw-write result checks for fallible transports.

Parameters
NameTypeDefault
valuelong—
value

Value for signed 64-bit, 8 bytes. Agree on the same format with the reader; a numeric type alone does not define message schema.

Put8void
# Put8
C#
public void Put8(sbyte value);

Writes 1 byte as signed 8-bit. Widths greater than one byte follow BigEndian. Returns no Error; use explicit raw-write result checks for fallible transports.

Parameters
NameTypeDefault
valuesbyte—
value

Value for signed 8-bit, 1 byte. Agree on the same format with the reader; a numeric type alone does not define message schema.

PutData2 overloads
# PutData · 1/2
C#
public Error PutData(byte[] data);

Writes raw bytes without an automatic header, length or reordering. Returns Error; full socket writes can wait. One call does not define a TCP message boundary.

Parameters
NameTypeDefault
databyte[]—
data

Raw bytes to write, not text or an automatically serialized structure. Array/span length specifies the byte count.

Returns Error

Error.Ok for successful complete transfer under the implementation contract; otherwise a failure code. Does not confirm receiver processing.

# PutData · 2/2
C#
public Error PutData(ReadOnlySpan<byte> data);

Writes raw bytes without an automatic header, length or reordering. Returns Error; full socket writes can wait. One call does not define a TCP message boundary.

Parameters
NameTypeDefault
dataReadOnlySpan<byte>—
data

Raw bytes to write, not text or an automatically serialized structure. Array/span length specifies the byte count.

Returns Error

Error.Ok for successful complete transfer under the implementation contract; otherwise a failure code. Does not confirm receiver processing.

PutDoublevoid
# PutDouble
C#
public void PutDouble(double value);

Writes 8 bytes as binary64. Widths greater than one byte follow BigEndian. Returns no Error; use explicit raw-write result checks for fallible transports.

Parameters
NameTypeDefault
valuedouble—
value

Value for binary64, 8 bytes. Agree on the same format with the reader; a numeric type alone does not define message schema.

PutFloatvoid
# PutFloat
C#
public void PutFloat(float value);

Writes 4 bytes as binary32. Widths greater than one byte follow BigEndian. Returns no Error; use explicit raw-write result checks for fallible transports.

Parameters
NameTypeDefault
valuefloat—
value

Value for binary32, 4 bytes. Agree on the same format with the reader; a numeric type alone does not define message schema.

PutHalfvoid
# PutHalf
C#
public void PutHalf(float value);

Writes 2 bytes as binary16. Widths greater than one byte follow BigEndian. Returns no Error; use explicit raw-write result checks for fallible transports. binary16 has less precision/range than C# float.

Parameters
NameTypeDefault
valuefloat—
value

Value for binary16, 2 bytes. Agree on the same format with the reader; a numeric type alone does not define message schema.

PutPartialData2 overloads
# PutPartialData · 1/2
C#
public Reckfell.Collections.Array PutPartialData(byte[] data);

Attempts a partial raw write and returns [Error, count]. Check both values and resume from the remaining portion when needed. A successful StreamPeerBuffer write normally accepts the entire array.

Parameters
NameTypeDefault
databyte[]—
data

Raw bytes to write, not text or an automatically serialized structure. Array/span length specifies the byte count.

Returns Reckfell.Collections.Array

Array [Error code, actual sent-byte count]. Success does not guarantee the entire request was sent.

# PutPartialData · 2/2
C#
public Reckfell.Collections.Array PutPartialData(ReadOnlySpan<byte> data);

Attempts a partial raw write and returns [Error, count]. Check both values and resume from the remaining portion when needed. A successful StreamPeerBuffer write normally accepts the entire array.

Parameters
NameTypeDefault
dataReadOnlySpan<byte>—
data

Raw bytes to write, not text or an automatically serialized structure. Array/span length specifies the byte count.

Returns Reckfell.Collections.Array

Array [Error code, actual sent-byte count]. Success does not guarantee the entire request was sent.

PutStringvoid
# PutString
C#
public void PutString(string value);

Writes ASCII representation with a 32-bit byte-length prefix. Use PutUtf8String for Unicode. Prefix byte order follows BigEndian; a terminator is not part of the payload string.

Parameters
NameTypeDefault
valuestring—
value

Text to write as ASCII. Use PutUtf8String for Cyrillic, emoji and other Unicode text.

PutU16void
# PutU16
C#
public void PutU16(ushort value);

Writes 2 bytes as unsigned 16-bit. Widths greater than one byte follow BigEndian. Returns no Error; use explicit raw-write result checks for fallible transports.

Parameters
NameTypeDefault
valueushort—
value

Value for unsigned 16-bit, 2 bytes. Agree on the same format with the reader; a numeric type alone does not define message schema.

PutU32void
# PutU32
C#
public void PutU32(uint value);

Writes 4 bytes as unsigned 32-bit. Widths greater than one byte follow BigEndian. Returns no Error; use explicit raw-write result checks for fallible transports.

Parameters
NameTypeDefault
valueuint—
value

Value for unsigned 32-bit, 4 bytes. Agree on the same format with the reader; a numeric type alone does not define message schema.

PutU64void
# PutU64
C#
public void PutU64(ulong value);

Writes 8 bytes as unsigned 64-bit. Widths greater than one byte follow BigEndian. Returns no Error; use explicit raw-write result checks for fallible transports.

Parameters
NameTypeDefault
valueulong—
value

Value for unsigned 64-bit, 8 bytes. Agree on the same format with the reader; a numeric type alone does not define message schema.

PutU8void
# PutU8
C#
public void PutU8(byte value);

Writes 1 byte as unsigned 8-bit. Widths greater than one byte follow BigEndian. Returns no Error; use explicit raw-write result checks for fallible transports.

Parameters
NameTypeDefault
valuebyte—
value

Value for unsigned 8-bit, 1 byte. Agree on the same format with the reader; a numeric type alone does not define message schema.

PutUtf8Stringvoid
# PutUtf8String
C#
public void PutUtf8String(string value);

Writes UTF-8 bytes with a 32-bit byte-length prefix. Emoji/Cyrillic byte count differs from C# string.Length. Read with GetUtf8String(), or consume the prefix separately and call GetUtf8String(byte_count).

Parameters
NameTypeDefault
valuestring—
value

Text to encode as UTF-8. The method writes its own 32-bit byte-length prefix before the payload.

PutVarvoid
# PutVar
C#
public void PutVar(Variant value, bool fullObjects = false);

Writes a 32-bit length and binary Variant representation. A separate engine format, not JSON or complete game-state serialization. BigEndian affects the outer prefix, not re-encoding the internal Variant format.

Parameters
NameTypeDefault
valueVariant—
fullObjectsboolfalse
value

Variant to encode in binary. The reader must use GetVar with the same outer-prefix byte order.

fullObjects

Default false does not store full Object contents. true enables object encoding, not transfer of owners, live trees or server resources between processes.

SetBigEndianvoid
# SetBigEndian
C#
public void SetBigEndian(bool enable);

Sets BigEndian for subsequent operations. Reader and writer must agree on byte order and field types.

Parameters
NameTypeDefault
enablebool—
enable

true selects big-endian, false little-endian for subsequent numeric operations; not input autodetection.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.