Skip to main content

Unity.Networking.Transport.NetworkPacketReceiver

The NetworkPacketReceiver is an interface for handling received packets, needed by the INetworkInterface It either can be used in two main scenarios:

  1. Your API requires a pointer to memory that you own. Then you should use AllocateMemory(ref Int32), write to the memory and then AppendPacket(IntPtr, ref NetworkInterfaceEndPoint, Int32, NetworkPacketReceiver.AppendPacketMode) with NoCopyNeeded. You don't need to deallocate the memory
  2. Your API gives you a pointer that you don't own. In this case you should use AppendPacket(IntPtr, ref NetworkInterfaceEndPoint, Int32, NetworkPacketReceiver.AppendPacketMode) with None (default)
Inherited Members#

ValueType.Equals(Object)

ValueType.GetHashCode()

ValueType.ToString()

Object.Equals(Object, Object)

Object.GetType()

Object.ReferenceEquals(Object, Object)

Namespace: System.Dynamic.ExpandoObject#
Assembly: transport.dll#
Syntax#
public struct NetworkPacketReceiver

LastUpdateTime#

Gets the value of the last update time.

Declaration#

public readonly long LastUpdateTime { get; }

Property Value#

TypeDescription
System.Int64

ReceiveErrorCode#

Sets the value of the receive error code

Declaration#

public int ReceiveErrorCode { set; }

Property Value#

TypeDescription
System.Int32

#

AllocateMemory(ref Int32)#

Calls NetworkDriver's AllocateMemory(ref Int32)

Declaration#

public IntPtr AllocateMemory(ref int dataLen)

Parameters#

TypeNameDescription
System.Int32dataLenSize of memory to allocate in bytes. Must be > 0

Returns#

TypeDescription
System.IntPtrPointer to allocated memory or IntPtr.Zero if there is no space left (this function doesn't set ReceiveErrorCode! caller should decide if this is Out of memory or something else)

AppendPacket(IntPtr, ref NetworkInterfaceEndPoint, Int32, NetworkPacketReceiver.AppendPacketMode)#

When data is received this function should be called to pass it inside NetworkDriver

Declaration#

public bool AppendPacket(IntPtr data, ref NetworkInterfaceEndPoint address, int dataLen, NetworkPacketReceiver.AppendPacketMode mode = NetworkPacketReceiver.AppendPacketMode.None)

Parameters#

TypeNameDescription
System.IntPtrdataPointer to the data. If it is pointer to data that was received with AllocateMemory(ref Int32) make sure mode is NoCopyNeeded>
NetworkInterfaceEndPointaddressAddress where data was received from
System.Int32dataLenLength of in bytes
NetworkPacketReceiver.AppendPacketModemodeExtra flags, like NoCopyNeeded that means - no copy is needed, data is already in NetworkDriver's data stream

Returns#

TypeDescription
System.BooleanTrue if no errors

IsAddressUsed(NetworkInterfaceEndPoint)#

Check if an address is currently associated with a valid connection. This is mostly useful to keep interface internal lists of connections in sync with the correct state.

Declaration#

public bool IsAddressUsed(NetworkInterfaceEndPoint address)

Parameters#

TypeNameDescription
NetworkInterfaceEndPointaddress

Returns#

TypeDescription
System.Boolean