StreamServer
Defined in: packages/node/src/net/stream-server.ts:29
Base class for stream-oriented servers.
This abstraction wraps a net.Server instance and exposes the lifecycle that is independent of the transport: binding state, connection accounting, event-loop referencing and closing.
Binding and address reporting are transport-specific and are added by the concrete subclasses TcpServer and IpcServer, as is the “connection” event, whose payload is a socket of the matching type.
Extends
Section titled “Extends”EventDispatcherMapBase<TEvents>
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”TServer
Section titled “TServer”TServer extends net.Server = net.Server
TEvents
Section titled “TEvents”TEvents extends StreamServerEvents = StreamServerEvents
Implements
Section titled “Implements”IEventDispatcherMap<TEvents>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new StreamServer<
TServer,TEvents>(server):StreamServer<TServer,TEvents>
Defined in: packages/node/src/net/stream-server.ts:43
Creates a new StreamServer instance.
Parameters
Section titled “Parameters”server
Section titled “server”TServer
The underlying Node.js server.
Returns
Section titled “Returns”StreamServer<TServer, TEvents>
Overrides
Section titled “Overrides”EventDispatcherMapBase<TEvents>.constructor
Accessors
Section titled “Accessors”listening
Section titled “listening”Get Signature
Section titled “Get Signature”get listening():
boolean
Defined in: packages/node/src/net/stream-server.ts:49
Whether the server is currently listening for connections.
Returns
Section titled “Returns”boolean
maxConnections
Section titled “maxConnections”Get Signature
Section titled “Get Signature”get maxConnections():
number
Defined in: packages/node/src/net/stream-server.ts:54
Maximum number of concurrent connections accepted by the server.
Returns
Section titled “Returns”number
Set Signature
Section titled “Set Signature”set maxConnections(
maxConnections):void
Defined in: packages/node/src/net/stream-server.ts:63
Updates the maximum number of concurrent connections.
Connections accepted beyond this limit are dropped.
Parameters
Section titled “Parameters”maxConnections
Section titled “maxConnections”number
Returns
Section titled “Returns”void
Methods
Section titled “Methods”close()
Section titled “close()”close():
Promise<void>
Defined in: packages/node/src/net/stream-server.ts:107
Stops the server from accepting new connections. Established connections are not closed; the promise resolves once the last of them ends.
Returns
Section titled “Returns”Promise<void>
A promise that resolves when the server is fully closed.
Throws
Section titled “Throws”When the server was not listening.
getConnections()
Section titled “getConnections()”getConnections():
Promise<number>
Defined in: packages/node/src/net/stream-server.ts:72
Counts the connections currently handled by the server.
Returns
Section titled “Returns”Promise<number>
A promise that resolves with the connection count.
isSubscribed()
Section titled “isSubscribed()”isSubscribed<
K>(event,listener):boolean
Defined in: packages/async/src/events/event-dispatcher-map-base.ts:38
Check if a callback is subscribed to a specific event.
Type Parameters
Section titled “Type Parameters”K extends string | number | symbol
Parameters
Section titled “Parameters”K
The event name.
listener
Section titled “listener”Callable<TEvents[K]>
The callback to check.
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”IEventDispatcherMap.isSubscribed
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.isSubscribed
ref():
void
Defined in: packages/node/src/net/stream-server.ts:88
Marks the server as referenced, preventing the Node.js process from exiting while it is listening.
Returns
Section titled “Returns”void
subscribe()
Section titled “subscribe()”subscribe<
K>(event,listener,options?):Callable|null
Defined in: packages/async/src/events/event-dispatcher-map-base.ts:23
Type Parameters
Section titled “Type Parameters”K extends string | number | symbol
Parameters
Section titled “Parameters”K
listener
Section titled “listener”Callable<TEvents[K]>
options?
Section titled “options?”EventDispatcherSubscribeOptions
Returns
Section titled “Returns”Callable | null
Implementation of
Section titled “Implementation of”IEventDispatcherMap.subscribe
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.subscribe
unref()
Section titled “unref()”unref():
void
Defined in: packages/node/src/net/stream-server.ts:96
Marks the server as unreferenced, allowing the Node.js process to exit even while it is listening.
Returns
Section titled “Returns”void
unsubscribe()
Section titled “unsubscribe()”unsubscribe<
K>(event,listener):void
Defined in: packages/async/src/events/event-dispatcher-map-base.ts:31
Unsubscribe a callback from a specific event.
Type Parameters
Section titled “Type Parameters”K extends string | number | symbol
Parameters
Section titled “Parameters”K
The event name.
listener
Section titled “listener”Callable<TEvents[K]>
The callback to remove.
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”IEventDispatcherMap.unsubscribe
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.unsubscribe
wait()
Section titled “wait()”wait<
K>(event,options?):Promise<TEvents[K]>
Defined in: packages/async/src/events/event-dispatcher-map-base.ts:45
Wait for the next occurrence of a specific event, optionally matching a predicate.
This is a convenience method that subscribes to the dispatcher, waits for the next event that matches the predicate (if provided), and then unsubscribes automatically.
Type Parameters
Section titled “Type Parameters”K extends string | number | symbol
Parameters
Section titled “Parameters”K
The event name to wait for.
options?
Section titled “options?”EventDispatcherWaitOptions<TEvents[K]>
Optional settings including predicate and abort signal.
Returns
Section titled “Returns”Promise<TEvents[K]>
A promise that resolves with the event arguments as an array.
Implementation of
Section titled “Implementation of”IEventDispatcherMap.wait
Inherited from
Section titled “Inherited from”EventDispatcherMapBase.wait