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.
Returns the local endpoint information of the socket.
Returns the remote endpoint information of the socket.
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.
Establishes a TCP connection to the specified port and host.
The port to connect to.
Optionalhost: stringThe host to connect to (defaults to localhost).
Optionaloptions: {Connection options.
OptionalautoSelectFamily?: booleanOptionalautoSelectFamilyAttemptTimeout?: numberOptionalblockList?: BlockListOptionalfamily?: numberOptionalhints?: numberOptionalkeepAlive?: booleanOptionalkeepAliveInitialDelay?: numberOptionallocalAddress?: stringOptionallocalPort?: numberOptionallookup?: LookupFunctionOptionalnoDelay?: booleanA promise that resolves when the connection is successfully established.
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.
Sets the keep-alive option for the socket.
Whether to enable keep-alive.
OptionalinitialDelay: numberThe initial delay in milliseconds before the first keep-alive probe.
Disables the Nagle algorithm for the socket.
Whether to disable the Nagle algorithm.
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
Staticfrom
TCP socket for establishing connections to TCP servers.
Example usage: