API reference / @jsprismarine/native-network / SharedPort
Class: SharedPort
Defined in: packages/native-network/src/SharedPort.ts:50
A UDP port libjuice owns and RakNet shares (ADR 0008).
Opening it binds the mux socket, dual-stack unless a bind address is given, and keeps it open with no peer connection on it. Every datagram is classified on libjuice's thread: RakNet's go to the rings of their address family, and STUN and DTLS stay with libjuice. A peer connection shares the port by being created with enableIceUdpMux and this port as its range.
Properties
port
readonlyport:number
Defined in: packages/native-network/src/SharedPort.ts:56
Methods
attach()
attach(
family,rings,wakePort):number
Defined in: packages/native-network/src/SharedPort.ts:84
Gives one address family's RakNet datagrams to a pair of rings, in the layout of SharedByteRing in @jsprismarine/raknet.
Parameters
family
4 | 6
4 or 6.
rings
The inbound ring, which this library writes, and the outbound one, which it reads.
inbound
SharedArrayBuffer
outbound
SharedArrayBuffer
wakePort
number
The loopback UDP port RakNet listens on for inbound wakes.
Returns
number
The loopback UDP port RakNet sends a byte to after writing a batch to the outbound ring.
Throws
When the memory is not a ring of a power-of-two capacity.
close()
close():
void
Defined in: packages/native-network/src/SharedPort.ts:132
Stops classifying; the socket closes once no peer connection is on it.
Returns
void
detach()
detach(
family):void
Defined in: packages/native-network/src/SharedPort.ts:108
Stops giving a family's datagrams to its rings.
Parameters
family
4 | 6
4 or 6.
Returns
void
stats()
stats():
SharedPortStats
Defined in: packages/native-network/src/SharedPort.ts:114
The port's counters.
Returns
open()
staticopen(network,port,bindAddress?):SharedPort
Defined in: packages/native-network/src/SharedPort.ts:67
Binds the port.
Parameters
network
The loaded library.
port
number
The UDP port.
bindAddress?
string = ''
The address to bind; every interface, dual-stack, when absent.
Returns
SharedPort
The open port.
Throws
When the port cannot be bound.