Options
All
  • Public
  • Public/Protected
  • All
Menu

Class NetlinkSocket

TODO

This socket silently discards invalid messages (see invalid event). FIXME: cork / uncork api FIXME: debug option, common for all sockets

Hierarchy

  • EventEmitter
    • NetlinkSocket

Index

Constructors

Properties

seq: number = 1

Methods

  • addMembership(group: number): void
  • Joins the specified multicast group

    Parameters

    • group: number

    Returns void

  • address(): { groups: number; port: number }
  • Return the address this socket is currently bound at.

    Returns { groups: number; port: number }

    Local address

    • groups: number
    • port: number
  • close(): void
  • Close the Netlink socket. After this, all other methods can no longer be called.

    Returns void

  • dropMembership(group: number): void
  • Leaves the specified multicast group

    Parameters

    • group: number

    Returns void

  • generateSeq(): number
  • Generate a unique sequence number to use in a message

    Returns number

  • getRecvBufferSize(): number
  • Returns the SO_RCVBUF socket receive buffer size in bytes

    Returns number

  • getSendBufferSize(): number
  • Returns the SO_SNDBUF socket send buffer size in bytes

    Returns number

  • ref(ref?: boolean): void
  • If true is passed, the socket will be kept referenced (preventing the event loop from exiting) even when there are no pending messages. Otherwise, the socket will be dereferenced when there are no pending messages.

    Parameters

    • Optional ref: boolean

      Socket ref state

    Returns void

  • Sends a message with the REQUEST and ACK flags set, and waits for a reply for the same sequence number.

    Note that this method doesn't check the origin of the reply, you should do that yourself.

    An array of mesages is returned. This will contain many items for multipart messages, zero if an ACK is received (and checkError isn't disabled) and one for other messages.

    Parameters

    Returns Promise<[NetlinkMessage[], MessageInfo]>

    Promise that resolves with [msg, rinfo] of the received message. The promise rejects if the message coudln't be sent or if the timeout expires. If checkError isn't disabled, the promise will also reject if an ERROR message is received.

  • send(type: number, data: Uint8Array | Uint8Array[], options?: NetlinkSendOptions, callback?: (error?: Error) => any): number
  • Send a Netlink message over the socket, addressed as the options indicate. By default, the sequence number and port will be filled automatically.

    Parameters

    • type: number

      Message type

    • data: Uint8Array | Uint8Array[]

      Message payload

    • Optional options: NetlinkSendOptions

      Message send options

    • Optional callback: (error?: Error) => any

      Callback will be called after the message has been sent (or failed to be sent)

        • (error?: Error): any
        • Parameters

          • Optional error: Error

          Returns any

    Returns number

    The sequence number of the sent message

  • setRecvBufferSize(size: number): any
  • Sets the SO_RCVBUF socket option. Sets the maximum socket receive buffer in bytes.

    Parameters

    • size: number

    Returns any

  • setSendBufferSize(size: number): any
  • Sets the SO_SNDBUF socket option. Sets the maximum socket send buffer in bytes.

    Parameters

    • size: number

    Returns any

  • unref(): void

Generated using TypeDoc