Gets whether the server is currently listening for connections.
Gets the maximum number of queued pending connections.
Sets the maximum number of queued pending connections.
The maximum number of connections to queue.
Gets the address information of the server.
The server's endpoint information or null if the server is not listening.
Closes the TCP server, stopping it from accepting new connections. Existing connections are not automatically closed.
A promise that resolves when the server is fully closed.
ProtecteddispatchDispatches an event to all listeners for the given event name.
The event name.
Arguments to pass to listeners.
Gets the current number of concurrent connections on the server.
A promise that resolves with the connection count.
Check if a callback is subscribed to a specific event.
The event name.
The callback to check.
Starts the TCP server listening on the specified port and host.
The port to listen on. If 0, a random available port will be assigned.
Optionalhost: stringThe host/interface to bind to. Defaults to '::' (IPv6) or '0.0.0.0' (IPv4).
Optionaloptions: {Additional listen options.
Optionalbacklog?: numberOptionalexclusive?: booleanOptionalipv6Only?: booleanOptionalpath?: stringOptionalreadableAll?: booleanOptionalreusePort?: booleanOptionalsignal?: AbortSignalWhen provided the corresponding AbortController can be used to cancel an asynchronous action.
OptionalwritableAll?: booleanA promise that resolves when the server is successfully listening.
References the server, preventing the process from exiting while the server is active.
Optionaloptions: EventDispatcherSubscribeOptionsUnreferences the server, allowing the process from exiting even if the server is active.
Unsubscribe a callback from a specific event.
The event name.
The callback to remove.
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.
The event name to wait for.
Optionaloptions: EventDispatcherWaitOptions<TcpServerEvents[K]>Optional settings including predicate and abort signal.
A promise that resolves with the event arguments as an array.
StaticfromCreates a new TcpServer instance with the specified options.
Optionaloptions: ServerOptsOptions for creating the TCP server.
A new TcpServer instance.
TCP server to accept incoming connections.
Example usage: