nx.js
NamespacesSwitchClasses

Socket

The Socket class represents a TCP connection, from which you can read and write data. A socket begins in a connected state (if the socket fails to connect, an error is thrown). While in a connected state, the socket’s ReadableStream and WritableStream can be read from and written to respectively.

Properties

PropertyModifierType
closedreadonlyPromise<void>
openedreadonlyPromise<SocketInfo>
readablereadonlyReadableStream<Uint8Array>
writablereadonlyWritableStream<Uint8Array>

Methods

close()

close(reason?): Promise<void>

Closes the socket and its underlying connection.

Parameters

ParameterType
reason?any

Returns

Promise<void>


startTls()

startTls(): Socket

Enables opportunistic TLS (otherwise known as StartTLS) which is a requirement for some protocols (primarily postgres/mysql and other DB protocols).

Returns

Socket

On this page