Class QUICSocket

Hierarchy

  • StartStop
    • QUICSocket

Constructors

Properties

[initLock]: RWLockWriter
_closed: boolean = false
_closedP: Promise<void>
_host: Host
_port: Port
_type: "ipv4" | "ipv6" | "ipv4&ipv6"
logger: Logger
resolveClosedP: (() => void)

Type declaration

    • (): void
    • Returns void

resolveHostname: ResolveHostname

Hostname resolver.

server?: QUICServer

Registered server for this socket. If a server is not registered for this socket, all packets for new connections will be dropped.

socket: Socket
socketBind: ((port, host) => Promise<void>)

Type declaration

    • (port, host): Promise<void>
    • Parameters

      • port: number
      • host: string

      Returns Promise<void>

socketClose: (() => Promise<void>)

Type declaration

    • (): Promise<void>
    • Returns Promise<void>

socketSend: ((...params) => Promise<number>)

Type declaration

    • (...params): Promise<number>
    • Parameters

      • Rest ...params: any[]

      Returns Promise<number>

Accessors

  • get [eventHandled](): ReadonlyWeakSet<Event>
  • Returns ReadonlyWeakSet<Event>

  • get [eventHandlers](): ReadonlyMap<string, Set<EventHandlerInfo>>
  • Returns ReadonlyMap<string, Set<EventHandlerInfo>>

  • get [eventTarget](): EventTarget
  • Returns EventTarget

  • get [handleEventError](): ((evt) => void)
  • Returns ((evt) => void)

      • (evt): void
      • Parameters

        • evt: EventError

        Returns void

  • get [running](): boolean
  • Returns boolean

  • get [statusP](): Promise<Status>
  • Returns Promise<Status>

  • get [status](): Status
  • Returns Status

  • get host(): Host
  • Gets the bound resolved host IP (not hostname). This can be the IPv4 or IPv6 address. This could be a wildcard address which means all interfaces. Note that :: can mean all IPv4 and all IPv6. Whereas 0.0.0.0 means only all IPv4.

    Returns Host

  • get port(): Port
  • Gets the bound resolved port. This cannot be 0. Because 0 is always resolved to a specific port.

    Returns Port

  • get type(): "ipv4" | "ipv6" | "ipv4&ipv6"
  • Gets the type of socket It can be ipv4-only, ipv6-only or dual stack

    Returns "ipv4" | "ipv6" | "ipv4&ipv6"

Methods

  • Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optional options: boolean | AddEventListenerOptions

    Returns void

  • Parameters

    • event: Event

    Returns boolean

  • Handles UDP socket message.

    The data buffer could be multiple coalesced QUIC packets. It could also be a non-QUIC packet data. If it is non-QUIC, we can discard the data. If there are multiple coalesced QUIC packets, it is expected that all packets are intended for the same connection. This means we only need to parse the first QUIC packet to determining what connection to route the data to.

    Parameters

    • data: Buffer
    • remoteInfo: RemoteInfo

    Returns Promise<void>

  • Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optional options: boolean | EventListenerOptions

    Returns void

  • Sends UDP datagram. Because UDP socket is connectionless, the port and address are required. This call is used internally by the rest of the library, but it is not internal because it can be used for hole punching, which is an application concern. Therefore if this method throws an exception, it does necessarily mean that this QUICSocket is an error state. It could be the caller's fault.

    Parameters

    • msg: string | readonly any[] | Uint8Array
    • port: number
    • address: string

    Returns Promise<number>

  • Parameters

    • msg: string | Uint8Array
    • offset: number
    • length: number
    • port: number
    • address: string

    Returns Promise<number>

  • Parameters

    • msg: string | Uint8Array
    • offset: number
    • length: number
    • port: number
    • address: string

    Returns Promise<number>

  • Starts this QUICSocket. This supports hostnames and IPv4 and IPv6 addresses. If the host is ::, this will also bind to 0.0.0.0.

    Parameters

    • opts: {
          host?: string;
          ipv6Only?: boolean;
          port?: number;
          reuseAddr?: boolean;
      } = {}
      • Optional host?: string

        The host to bind to. Default is ::.

      • Optional ipv6Only?: boolean

        Whether to only bind to IPv6. Default is false.

      • Optional port?: number

        The port to bind to. Default is 0.

      • Optional reuseAddr?: boolean

        Whether to reuse the address. Default is false.

    Returns Promise<void>

    Throws

    If bind failed due to EINVAL or ENOTFOUND. EINVAL is due to using IPv4 host when creating a udp6 socket. ENOTFOUND is when the hostname does not resolve or does not resolve to IPv6 when creating a udp6 socket or does not resolve to IPv4 when creating a udp4 socket.

  • Stop this QUICSocket.

    Parameters

    • opts: {
          force?: boolean;
      } = {}
      • Optional force?: boolean

        Stop the socket even if the connection map is not empty.

    Returns Promise<void>

    Throws

Generated using TypeDoc