Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DatagramSocket

A datagram socket can be used to send DatagramPacket's to remote datagram servers and receive DatagramPackets .

Usually you use a datagram socket to send UDP over the wire. UDP is connection-less which means you are not connected to the remote peer in a persistent way. Because of this you have to supply the address and port of the remote peer when sending data.

You can send data to ipv4 or ipv6 addresses, which also include multicast addresses.

Please consult the documentation for more information on datagram sockets.

Hierarchy

  • DatagramSocket

Implements

Index

Methods

blockMulticastGroup

  • blockMulticastGroup(multicastAddress: string, sourceToBlock: string): PromiseLike<void>
  • blockMulticastGroup(multicastAddress: string, sourceToBlock: string, handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): DatagramSocket
  • blockMulticastGroup(multicastAddress: string, networkInterface: string, sourceToBlock: string): PromiseLike<void>
  • blockMulticastGroup(multicastAddress: string, networkInterface: string, sourceToBlock: string, handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): DatagramSocket
  • Block the given address for the given multicast address and notifies the once the operation completes.

    Parameters

    • multicastAddress: string
    • sourceToBlock: string

    Returns PromiseLike<void>

  • Block the given address for the given multicast address and notifies the once the operation completes.

    Parameters

    Returns DatagramSocket

  • Block the given address for the given multicast address on the given network interface and notifies the once the operation completes.

    Parameters

    • multicastAddress: string
    • networkInterface: string
    • sourceToBlock: string

    Returns PromiseLike<void>

  • Block the given address for the given multicast address on the given network interface and notifies the once the operation completes.

    Parameters

    • multicastAddress: string
    • networkInterface: string
    • sourceToBlock: string
    • handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns DatagramSocket

close

  • Closes the DatagramSocket implementation asynchronous and notifies the handler once done.

    Returns PromiseLike<void>

  • Closes the DatagramSocket implementation asynchronous and notifies the handler once done.

    Parameters

    Returns void

endHandler

  • Parameters

    • endHandler: ((res: void) => void) | Handler<void> | null | undefined

    Returns DatagramSocket

exceptionHandler

fetch

  • Parameters

    • amount: number

    Returns DatagramSocket

handler

isMetricsEnabled

  • isMetricsEnabled(): boolean
  • Whether the metrics are enabled for this measured object

    Returns boolean

listen

  • Start listening on the given port and host. The handler will be called when the socket is listening.

    Parameters

    • port: number
    • host: string

    Returns PromiseLike<DatagramSocket>

  • Start listening on the given port and host. The handler will be called when the socket is listening.

    Parameters

    Returns DatagramSocket

listenMulticastGroup

  • listenMulticastGroup(multicastAddress: string): PromiseLike<void>
  • listenMulticastGroup(multicastAddress: string, handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): DatagramSocket
  • listenMulticastGroup(multicastAddress: string, networkInterface: string, source: string | null | undefined): PromiseLike<void>
  • listenMulticastGroup(multicastAddress: string, networkInterface: string, source: string | null | undefined, handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): DatagramSocket
  • Joins a multicast group and listens for packets send to it. The is notified once the operation completes.

    Parameters

    • multicastAddress: string

    Returns PromiseLike<void>

  • Joins a multicast group and listens for packets send to it. The is notified once the operation completes.

    Parameters

    Returns DatagramSocket

  • Joins a multicast group and listens for packets send to it on the given network interface. The is notified once the operation completes.

    Parameters

    • multicastAddress: string
    • networkInterface: string
    • source: string | null | undefined

    Returns PromiseLike<void>

  • Joins a multicast group and listens for packets send to it on the given network interface. The is notified once the operation completes.

    Parameters

    • multicastAddress: string
    • networkInterface: string
    • source: string | null | undefined
    • handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns DatagramSocket

localAddress

pause

pipe

  • Pause this stream and return a to transfer the elements of this stream to a destination .

    The stream will be resumed when the pipe will be wired to a WriteStream.

    Returns Pipe<DatagramPacket>

pipeTo

  • Pipe this ReadStream to the WriteStream.

    Elements emitted by this stream will be written to the write stream until this stream ends or fails.

    Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

    Parameters

    Returns PromiseLike<void>

  • Pipe this ReadStream to the WriteStream.

    Elements emitted by this stream will be written to the write stream until this stream ends or fails.

    Once this stream has ended or failed, the write stream will be ended and the handler will be called with the result.

    Parameters

    Returns void

resume

send

  • Write the given Buffer to the SocketAddress. The Handler will be notified once the write completes.

    Parameters

    • packet: Buffer
    • port: number
    • host: string

    Returns PromiseLike<void>

  • Write the given Buffer to the SocketAddress. The Handler will be notified once the write completes.

    Parameters

    Returns DatagramSocket

  • Write the given String to the SocketAddress using UTF8 encoding. The will be notified once the write completes.

    Parameters

    • str: string
    • port: number
    • host: string

    Returns PromiseLike<void>

  • Write the given String to the SocketAddress using UTF8 encoding. The will be notified once the write completes.

    Parameters

    Returns DatagramSocket

  • Write the given String to the SocketAddress using the given encoding. The will be notified once the write completes.

    Parameters

    • str: string
    • enc: string
    • port: number
    • host: string

    Returns PromiseLike<void>

  • Write the given String to the SocketAddress using the given encoding. The will be notified once the write completes.

    Parameters

    Returns DatagramSocket

sender

  • Returns a WriteStream able to send to the SocketAddress.

    Parameters

    • port: number
    • host: string

    Returns WriteStream<Buffer>

unlistenMulticastGroup

  • unlistenMulticastGroup(multicastAddress: string): PromiseLike<void>
  • unlistenMulticastGroup(multicastAddress: string, handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): DatagramSocket
  • unlistenMulticastGroup(multicastAddress: string, networkInterface: string, source: string | null | undefined): PromiseLike<void>
  • unlistenMulticastGroup(multicastAddress: string, networkInterface: string, source: string | null | undefined, handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>): DatagramSocket
  • Leaves a multicast group and stops listening for packets send to it. The is notified once the operation completes.

    Parameters

    • multicastAddress: string

    Returns PromiseLike<void>

  • Leaves a multicast group and stops listening for packets send to it. The is notified once the operation completes.

    Parameters

    Returns DatagramSocket

  • Leaves a multicast group and stops listening for packets send to it on the given network interface. The is notified once the operation completes.

    Parameters

    • multicastAddress: string
    • networkInterface: string
    • source: string | null | undefined

    Returns PromiseLike<void>

  • Leaves a multicast group and stops listening for packets send to it on the given network interface. The is notified once the operation completes.

    Parameters

    • multicastAddress: string
    • networkInterface: string
    • source: string | null | undefined
    • handler: ((res: AsyncResult<void>) => void) | Handler<AsyncResult<void>>

    Returns DatagramSocket

Generated using TypeDoc