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.
ProtecteddispatchDispatches an event to all listeners for the given event name.
The event name.
Arguments to pass to listeners.
Half-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.
Check if a callback is subscribed to a specific event.
The event name.
The callback to check.
Marks the socket as referenced, preventing the Node.js process from exiting while the socket is active.
ProtectedsetupOptionaloptions: EventDispatcherSubscribeOptionsMarks the socket as unreferenced, allowing the Node.js process to exit even if the socket is still 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<TlsSocketEvents[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: {Options for creating the underlying Node.js socket.
OptionalALPNProtocols?: readonly string[] | ArrayBufferView<ArrayBufferLike>An array of strings or a Buffer naming possible ALPN protocols. (Protocols should be ordered by their priority.)
OptionalenableTrace?: booleanWhen enabled, TLS packet trace information is written to stderr. This can be
used to debug TLS connection problems.
OptionalrejectUnauthorized?: booleanIf true the server will reject any connection which is not authorized with the list of supplied CAs. This option only has an effect if requestCert is true.
OptionalrequestCert?: booleanIf true the server will request a certificate from clients that connect and attempt to verify that certificate. Defaults to false.
OptionalrequestOCSP?: booleanIf true, specifies that the OCSP status request extension will be added to the client hello and an 'OCSPResponse' event will be emitted on the socket before establishing a secure communication
OptionalsecureContext?: SecureContextAn optional TLS context object from tls.createSecureContext()
Optionalsession?: Buffer<ArrayBufferLike>An optional Buffer instance containing a TLS session.
OptionalSNICallback?: (SNICallback(servername, cb)
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.