Nudp
Bun

namespace

udp

namespace udp

  • interface BaseUDPSocket

    • readonly binaryType: keyof BinaryTypeList
    • readonly closed: boolean
    • readonly hostname: string
    • readonly port: number
    • multicastAddress: string,
      interfaceAddress?: string
      ): boolean;

      Join a multicast group.

      @param multicastAddress

      The multicast group address

      @param interfaceAddress

      Optional interface address to use

      @returns

      true on success

    • sourceAddress: string,
      groupAddress: string,
      interfaceAddress?: string
      ): boolean;

      Join a source-specific multicast group.

      @param sourceAddress

      The source address

      @param groupAddress

      The multicast group address

      @param interfaceAddress

      Optional interface address to use

      @returns

      true on success

    • close(): void;
    • multicastAddress: string,
      interfaceAddress?: string
      ): boolean;

      Leave a multicast group.

      @param multicastAddress

      The multicast group address

      @param interfaceAddress

      Optional interface address to use

      @returns

      true on success

    • sourceAddress: string,
      groupAddress: string,
      interfaceAddress?: string
      ): boolean;

      Leave a source-specific multicast group.

      @param sourceAddress

      The source address

      @param groupAddress

      The multicast group address

      @param interfaceAddress

      Optional interface address to use

      @returns

      true on success

    • ref(): void;
    • enabled: boolean
      ): boolean;

      Enable or disable SO_BROADCAST socket option.

      @param enabled

      Whether to enable broadcast

      @returns

      The enabled value

    • interfaceAddress: string
      ): boolean;

      Set the IP_MULTICAST_IF socket option to specify the outgoing interface for multicast packets.

      @param interfaceAddress

      The address of the interface to use

      @returns

      true on success

    • enabled: boolean
      ): boolean;

      Enable or disable IP_MULTICAST_LOOP socket option.

      @param enabled

      Whether to enable multicast loopback

      @returns

      The enabled value

    • ttl: number
      ): number;

      Set the IP_MULTICAST_TTL socket option.

      @param ttl

      Time to live value for multicast packets

      @returns

      The TTL value

    • ttl: number
      ): number;

      Set the IP_TTL socket option.

      @param ttl

      Time to live value

      @returns

      The TTL value

    • unref(): void;
  • interface ConnectedSocket<DataBinaryType extends BinaryType>

    • readonly binaryType: keyof BinaryTypeList
    • readonly closed: boolean
    • readonly hostname: string
    • readonly port: number
    • multicastAddress: string,
      interfaceAddress?: string
      ): boolean;

      Join a multicast group.

      @param multicastAddress

      The multicast group address

      @param interfaceAddress

      Optional interface address to use

      @returns

      true on success

    • sourceAddress: string,
      groupAddress: string,
      interfaceAddress?: string
      ): boolean;

      Join a source-specific multicast group.

      @param sourceAddress

      The source address

      @param groupAddress

      The multicast group address

      @param interfaceAddress

      Optional interface address to use

      @returns

      true on success

    • close(): void;
    • multicastAddress: string,
      interfaceAddress?: string
      ): boolean;

      Leave a multicast group.

      @param multicastAddress

      The multicast group address

      @param interfaceAddress

      Optional interface address to use

      @returns

      true on success

    • sourceAddress: string,
      groupAddress: string,
      interfaceAddress?: string
      ): boolean;

      Leave a source-specific multicast group.

      @param sourceAddress

      The source address

      @param groupAddress

      The multicast group address

      @param interfaceAddress

      Optional interface address to use

      @returns

      true on success

    • ref(): void;
    • handler: ConnectedSocketHandler<DataBinaryType>
      ): void;
    • data: Data
      ): boolean;
    • packets: readonly Data[]
      ): number;
    • enabled: boolean
      ): boolean;

      Enable or disable SO_BROADCAST socket option.

      @param enabled

      Whether to enable broadcast

      @returns

      The enabled value

    • interfaceAddress: string
      ): boolean;

      Set the IP_MULTICAST_IF socket option to specify the outgoing interface for multicast packets.

      @param interfaceAddress

      The address of the interface to use

      @returns

      true on success

    • enabled: boolean
      ): boolean;

      Enable or disable IP_MULTICAST_LOOP socket option.

      @param enabled

      Whether to enable multicast loopback

      @returns

      The enabled value

    • ttl: number
      ): number;

      Set the IP_MULTICAST_TTL socket option.

      @param ttl

      Time to live value for multicast packets

      @returns

      The TTL value

    • ttl: number
      ): number;

      Set the IP_TTL socket option.

      @param ttl

      Time to live value

      @returns

      The TTL value

    • unref(): void;
  • interface ConnectedSocketHandler<DataBinaryType extends BinaryType>

  • interface ConnectSocketOptions<DataBinaryType extends BinaryType>

  • interface Socket<DataBinaryType extends BinaryType>

    • readonly binaryType: keyof BinaryTypeList
    • readonly closed: boolean
    • readonly hostname: string
    • readonly port: number
    • multicastAddress: string,
      interfaceAddress?: string
      ): boolean;

      Join a multicast group.

      @param multicastAddress

      The multicast group address

      @param interfaceAddress

      Optional interface address to use

      @returns

      true on success

    • sourceAddress: string,
      groupAddress: string,
      interfaceAddress?: string
      ): boolean;

      Join a source-specific multicast group.

      @param sourceAddress

      The source address

      @param groupAddress

      The multicast group address

      @param interfaceAddress

      Optional interface address to use

      @returns

      true on success

    • close(): void;
    • multicastAddress: string,
      interfaceAddress?: string
      ): boolean;

      Leave a multicast group.

      @param multicastAddress

      The multicast group address

      @param interfaceAddress

      Optional interface address to use

      @returns

      true on success

    • sourceAddress: string,
      groupAddress: string,
      interfaceAddress?: string
      ): boolean;

      Leave a source-specific multicast group.

      @param sourceAddress

      The source address

      @param groupAddress

      The multicast group address

      @param interfaceAddress

      Optional interface address to use

      @returns

      true on success

    • ref(): void;
    • handler: SocketHandler<DataBinaryType>
      ): void;
    • data: Data,
      port: number,
      address: string
      ): boolean;
    • packets: readonly number | Data[]
      ): number;
    • enabled: boolean
      ): boolean;

      Enable or disable SO_BROADCAST socket option.

      @param enabled

      Whether to enable broadcast

      @returns

      The enabled value

    • interfaceAddress: string
      ): boolean;

      Set the IP_MULTICAST_IF socket option to specify the outgoing interface for multicast packets.

      @param interfaceAddress

      The address of the interface to use

      @returns

      true on success

    • enabled: boolean
      ): boolean;

      Enable or disable IP_MULTICAST_LOOP socket option.

      @param enabled

      Whether to enable multicast loopback

      @returns

      The enabled value

    • ttl: number
      ): number;

      Set the IP_MULTICAST_TTL socket option.

      @param ttl

      Time to live value for multicast packets

      @returns

      The TTL value

    • ttl: number
      ): number;

      Set the IP_TTL socket option.

      @param ttl

      Time to live value

      @returns

      The TTL value

    • unref(): void;
  • interface SocketHandler<DataBinaryType extends BinaryType>

    • socket: Socket<DataBinaryType>,
      data: BinaryTypeList[DataBinaryType],
      port: number,
      address: string
      ): void | Promise<void>;
    • socket: Socket<DataBinaryType>
      ): void | Promise<void>;
    • socket: Socket<DataBinaryType>,
      error: Error
      ): void | Promise<void>;
  • interface SocketOptions<DataBinaryType extends BinaryType>

  • type Data = string | ArrayBufferView | ArrayBufferLike