# Class: DatagramSocket

## vertx-js/datagram_socket~ DatagramSocket

#### new DatagramSocket()

  Source:
    - datagram_socket.js, line 34

### Methods

#### blockMulticastGroup(multicastAddress, networkInterface, sourceToBlock, handler) → {DatagramSocket}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `multicastAddress` | string | the address for which you want to block the source address
  `networkInterface` | string | the network interface on which the blocking should occur.
  `sourceToBlock` | string | the source address which should be blocked. You will not receive an multicast packets for it anymore.
  `handler` | function | the handler to notify once the operation completes

  Source:
    - datagram_socket.js, line 234

  ##### Returns:

  a reference to this, so the API can be used fluently
  Type
    DatagramSocket

#### close(handler)

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function | the handler to notify once complete

  Source:
    - datagram_socket.js, line 122

#### endHandler(endHandler) → {DatagramSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `endHandler` | function |

  Source:
    - datagram_socket.js, line 314

  ##### Returns:

  Type
    DatagramSocket

#### exceptionHandler(handler) → {DatagramSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function |

  Source:
    - datagram_socket.js, line 344

  ##### Returns:

  Type
    DatagramSocket

#### handler(handler) → {DatagramSocket}

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `handler` | function |

  Source:
    - datagram_socket.js, line 328

  ##### Returns:

  Type
    DatagramSocket

#### isMetricsEnabled() → {boolean}

  Whether the metrics are enabled for this measured object
  Source:
    - datagram_socket.js, line 48

  ##### Returns:

  true if the metrics are enabled
  Type
    boolean

#### listen(port, host, handler) → {DatagramSocket}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | number | the port to listen on
  `host` | string | the host to listen on
  `handler` | function | the handler will be called when listening

  Source:
    - datagram_socket.js, line 266

  ##### Returns:

  a reference to this, so the API can be used fluently
  Type
    DatagramSocket

#### listenMulticastGroup(multicastAddress, networkInterface, source, handler) → {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:

  Name | Type | Description
  --- | --- | ---
  `multicastAddress` | string | the address of the multicast group to join
  `networkInterface` | string | the network interface on which to listen for packets.
  `source` | string | the address of the source for which we will listen for multicast packets
  `handler` | function | then handler to notify once the operation completes

  Source:
    - datagram_socket.js, line 166

  ##### Returns:

  a reference to this, so the API can be used fluently
  Type
    DatagramSocket

#### localAddress() → {SocketAddress}

  Return the SocketAddress to which this DatagramSocket is bound.
  Source:
    - datagram_socket.js, line 145

  ##### Returns:

  the socket address
  Type
    SocketAddress

#### pause() → {DatagramSocket}

  Source:
    - datagram_socket.js, line 286

  ##### Returns:

  Type
    DatagramSocket

#### resume() → {DatagramSocket}

  Source:
    - datagram_socket.js, line 300

  ##### Returns:

  Type
    DatagramSocket

#### send(str, enc, port, host, handler) → {DatagramSocket}

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

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `str` | string | the String to write
  `enc` | string | the charset used for encoding
  `port` | number | the host port of the remote peer
  `host` | string | the host address of the remote peer
  `handler` | function | the Handler to notify once the write completes.

  Source:
    - datagram_socket.js, line 67

  ##### Returns:

  a reference to this, so the API can be used fluently
  Type
    DatagramSocket

#### sender(port, host) → {PacketWritestream}

  Returns a PacketWritestream able to send to the SocketAddress.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `port` | number | the port of the remote peer
  `host` | string | the host address of the remote peer

  Source:
    - datagram_socket.js, line 108

  ##### Returns:

  the write stream for sending packets
  Type
    PacketWritestream

#### unlistenMulticastGroup(multicastAddress, networkInterface, source, handler) → {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:

  Name | Type | Description
  --- | --- | ---
  `multicastAddress` | string | the address of the multicast group to join
  `networkInterface` | string | the network interface on which to listen for packets.
  `source` | string | the address of the source for which we will listen for multicast packets
  `handler` | function | the handler to notify once the operation completes

  Source:
    - datagram_socket.js, line 200

  ##### Returns:

  a reference to this, so the API can be used fluently
  Type
    DatagramSocket