API reference
Preparing search index…

Socket

Abstract

Common base for Node network transports; defaults to blocking semantics implemented with asynchronous waits.

Type hierarchy

Hierarchy (View Summary)

Source & inheritance
Member directory27

Constructors

Properties

Methods

Constructors

Properties

blocking: boolean = true
Source & inheritance
detach?: () => void

Remove event listeners from the current transport.

Source & inheritance
epoch: number = 0
Source & inheritance
failure?: Error
Source & inheritance
transport?: SocketHandle

Currently owned Node transport, released by Node on close or recreation.

Source & inheritance
AnyPort: 0

Let the system assign an available port when binding.

Source & inheritance
Status: typeof SocketStatus = SocketStatus

Socket operation status enumeration.

Source & inheritance
Type: typeof SocketType = SocketType

Socket transport protocol enumeration.

Source & inheritance

Methods

  • Parameters

    check
    () => boolean
    generation
    number

    Returns

    Promise<boolean>
    Source & inheritance
  • Close the current transport and wake waits from the previous generation. Repeated calls are safe; the blocking flag is unchanged.

    Returns

    void
    Source & inheritance
  • Return the latest underlying error, or undefined if none is recorded.

    Returns

    undefined | Error
    Source & inheritance
  • By default, TCP readiness follows readable bytes and write backpressure; bound UDP sockets can send. Subclasses report UDP datagrams and Server connection queues to Selector through this hook and changed().

    Parameters

    mask
    number

    Returns

    number
    Source & inheritance
  • By default, check whether the Node transport is alive; subclasses may override this without importing internal symbols.

    Returns

    boolean
    Source & inheritance
  • Return whether blocking semantics use asynchronous waits.

    Returns

    boolean
    Source & inheritance
  • Clean up subclass state on close; the old transport is already detached when this is called.

    Returns

    void
    Source & inheritance
  • Install default TCP/UDP/Server state listeners; subclasses may override this to manage their own send/receive queues.

    Returns

    void
    Source & inheritance
  • Set whether to wait asynchronously for readability/writability. When false, return NotReady or Partial according to current queue state.

    Parameters

    blocking
    boolean

    Returns

    void
    Source & inheritance
  • Validate the transport type before adoption to avoid discovering a type error after closing the old connection.

    Parameters

    Returns

    void
    Source & inheritance

Symbol members

"[socketEvents]": EventEmitter<DefaultEventMap> = ...
Source & inheritance
  • Expose overridable liveness state to Selector.

    Returns

    boolean
    Source & inheritance
  • Expose overridable readiness conditions to Selector.

    Parameters

    mask
    number

    Returns

    number
    Source & inheritance

Icons made by Lorc, Delapouite & Skoll · game-icons.net · CC BY 3.0