Creates a new StreamSocket instance.
The underlying Node.js socket.
Protected ReadonlyhandledProtected ReadonlysockThe underlying Node.js socket.
Total number of bytes read from the socket so far.
Total number of bytes written to the socket so far.
Indicates whether the socket has been fully closed.
Whether the socket is currently in the process of connecting.
Indicates whether the underlying socket has been destroyed.
Underlying duplex stream for reading and writing data.
This is the wrapped net.Socket instance and can be passed directly to APIs that expect a Node.js stream.
Current inactivity timeout in milliseconds, or null if disabled.
Updates the inactivity timeout for the socket.
When set to a positive number, the socket emits a "timeout" event
if no I/O activity occurs within the given number of milliseconds.
A value of 0 or null disables the timeout entirely.
Immediately destroys the underlying socket.
Pending I/O is discarded, the connection is closed and the socket transitions to a terminal state. Any registered "close" listeners will still be invoked.
ProtecteddispatchHalf-closes the socket, optionally waiting for a full close.
If waitForClose is omitted or false, the promise resolves once
the local side has finished sending data and the FIN has been
queued. When waitForClose is true, the promise resolves only
after the remote side has also closed and the "close" event has
fired.
Optionaloptions: { waitForClose?: boolean }Optional settings for ending the socket.
A promise that resolves once the socket has ended.
Marks the socket as referenced, preventing the Node.js process from exiting while the socket is active.
ProtectedsetupMarks the socket as unreferenced, allowing the Node.js process to exit even if the socket is still active.
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<TEvents[K]>Optional settings including predicate and abort signal.
A promise that resolves with the event arguments as an array.
Writes data to the socket and resolves once the write completes.
The data to write
StaticfromCreates a new StreamSocket instance.
Optionaloptions: SocketConstructorOptsOptions for creating the underlying Node.js socket.
A new StreamSocket instance.
Base class for stream-oriented client sockets.
This abstraction wraps a net.Socket instance and exposes:
It is intentionally transport-agnostic: it does not assume a particular address family or protocol. Concrete subclasses such as TcpClient add protocol-specific concerns (for example
InetEndpointaccessors, TCP keep-alive configuration, or DNS resolution events) on top of this base.Unless explicitly documented otherwise, methods mirror the semantics of their underlying net.Socket counterparts.