vertx-lang-scala-docs_2.12 3.4.1 API < Back
 

# Packages

-  package root
  Definition Classes
    root
-  package io
  Definition Classes
    root
-  package vertx
  Definition Classes
    io
-  package scala
  Definition Classes
    vertx
-  package core
  Definition Classes
    scala
-  package datagram
  Definition Classes
    core
- DatagramPacket
- DatagramSocket
- DatagramSocketOptions

c

io.vertx.scala.core.datagram

# DatagramSocket 

###
Companion object DatagramSocket

#### class DatagramSocket extends ReadStream[DatagramPacket] with Measured

A datagram socket can be used to send io.vertx.scala.core.datagram.DatagramPacket's to remote datagram servers and receive io.vertx.scala.core.datagram.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.

Linear Supertypes
Measured, ReadStream[DatagramPacket], StreamBase, AnyRef, Any
 
Ordering

1. Alphabetic
2. By Inheritance

Inherited

1. DatagramSocket
2. Measured
3. ReadStream
4. StreamBase
5. AnyRef
6. Any

1. Hide All
2. Show All

Visibility

1. Public
2. All

### Instance Constructors

1.  new DatagramSocket(_asJava: AnyRef)

### Value Members

1.  final def !=(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
2.  final def ##(): Int
   Definition Classes
     AnyRef → Any
3.  final def ==(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
4.  final def asInstanceOf[T0]: T0
   Definition Classes
     Any
5.  def asJava: AnyRef
   Definition Classes
     DatagramSocket → Measured → ReadStream → StreamBase
6.  def blockMulticastGroup(multicastAddress: String, networkInterface: String, sourceToBlock: String, handler: Handler[AsyncResult[DatagramSocket]]): DatagramSocket

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

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

   multicastAddress

     the address for which you want to block the source address

   networkInterface

     the network interface on which the blocking should occur.

   sourceToBlock

     the source address which should be blocked. You will not receive an multicast packets for it anymore.

   handler

     the handler to notify once the operation completes

   returns

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

7.  def blockMulticastGroup(multicastAddress: String, sourceToBlock: String, handler: Handler[AsyncResult[DatagramSocket]]): DatagramSocket

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

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

   multicastAddress

     the address for which you want to block the source address

   sourceToBlock

     the source address which should be blocked. You will not receive an multicast packets for it anymore.

   handler

     the handler to notify once the operation completes

   returns

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

8.  def blockMulticastGroupFuture(multicastAddress: String, networkInterface: String, sourceToBlock: String): scala.concurrent.Future[DatagramSocket]

   Like blockMulticastGroup but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

9.  def blockMulticastGroupFuture(multicastAddress: String, sourceToBlock: String): scala.concurrent.Future[DatagramSocket]

   Like blockMulticastGroup but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

10.  def clone(): AnyRef
    Attributes
      protected[java.lang]
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
11.  def close(): Unit

    Closes the io.vertx.scala.core.datagram.DatagramSocket.

    Closes the io.vertx.scala.core.datagram.DatagramSocket. The close itself is asynchronous.

12.  def close(handler: Handler[AsyncResult[Unit]]): Unit

    Closes the io.vertx.scala.core.datagram.DatagramSocket implementation asynchronous and notifies the handler once done.

    Closes the io.vertx.scala.core.datagram.DatagramSocket implementation asynchronous and notifies the handler once done.

    handler

      the handler to notify once complete

13.  def closeFuture(): scala.concurrent.Future[Unit]

    Like close but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

14.  def endHandler(endHandler: Handler[Unit]): DatagramSocket

    Set an end handler.

    Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.

    returns

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

    Definition Classes
      DatagramSocket → ReadStream
15.  final def eq(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
16.  def equals(arg0: Any): Boolean
    Definition Classes
      AnyRef → Any
17.  def exceptionHandler(handler: Handler[Throwable]): DatagramSocket

    Set an exception handler on the read stream.

    Set an exception handler on the read stream.

    handler

      the exception handler

    returns

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

    Definition Classes
      DatagramSocket → ReadStream → StreamBase
18.  def finalize(): Unit
    Attributes
      protected[java.lang]
    Definition Classes
      AnyRef
    Annotations
      @throws( classOf[java.lang.Throwable] )
19.  final def getClass(): Class[_]
    Definition Classes
      AnyRef → Any
20.  def handler(handler: Handler[DatagramPacket]): DatagramSocket

    Set a data handler.

    Set a data handler. As data is read, the handler will be called with the data.

    returns

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

    Definition Classes
      DatagramSocket → ReadStream
21.  def hashCode(): Int
    Definition Classes
      AnyRef → Any
22.  final def isInstanceOf[T0]: Boolean
    Definition Classes
      Any
23.  def isMetricsEnabled(): Boolean

    Whether the metrics are enabled for this measured object

    Whether the metrics are enabled for this measured object

    returns

      true if the metrics are enabled

    Definition Classes
      DatagramSocket → Measured
24.  def listen(port: Int, host: String, handler: Handler[AsyncResult[DatagramSocket]]): DatagramSocket

    Start listening on the given port and host.

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

    port

      the port to listen on

    host

      the host to listen on

    handler

      the handler will be called when listening

    returns

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

25.  def listenFuture(port: Int, host: String): scala.concurrent.Future[DatagramSocket]

    Like listen but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

26.  def listenMulticastGroup(multicastAddress: String, networkInterface: String, source: Option[String], handler: Handler[AsyncResult[DatagramSocket]]): DatagramSocket

    Joins a multicast group and listens for packets send to it on the given network interface.

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

    multicastAddress

      the address of the multicast group to join

    networkInterface

      the network interface on which to listen for packets.

    source

      the address of the source for which we will listen for multicast packets

    handler

      then handler to notify once the operation completes

    returns

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

27.  def listenMulticastGroup(multicastAddress: String, handler: Handler[AsyncResult[DatagramSocket]]): DatagramSocket

    Joins a multicast group and listens for packets send to it.

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

    multicastAddress

      the address of the multicast group to join

    handler

      then handler to notify once the operation completes

    returns

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

28.  def listenMulticastGroupFuture(multicastAddress: String, networkInterface: String, source: Option[String]): scala.concurrent.Future[DatagramSocket]

    Like listenMulticastGroup but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

29.  def listenMulticastGroupFuture(multicastAddress: String): scala.concurrent.Future[DatagramSocket]

    Like listenMulticastGroup but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

30.  def localAddress(): SocketAddress

    Return the io.vertx.scala.core.net.SocketAddress to which this io.vertx.scala.core.datagram.DatagramSocket is bound.

    Return the io.vertx.scala.core.net.SocketAddress to which this io.vertx.scala.core.datagram.DatagramSocket is bound.

    returns

      the socket address

31.  final def ne(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
32.  final def notify(): Unit
    Definition Classes
      AnyRef
33.  final def notifyAll(): Unit
    Definition Classes
      AnyRef
34.  def pause(): DatagramSocket

    Pause the `ReadSupport`.

    Pause the `ReadSupport`. While it's paused, no data will be sent to the `dataHandler`

    returns

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

    Definition Classes
      DatagramSocket → ReadStream
35.  def resume(): DatagramSocket

    Resume reading.

    Resume reading. If the `ReadSupport` has been paused, reading will recommence on it.

    returns

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

    Definition Classes
      DatagramSocket → ReadStream
36.  def send(str: String, enc: String, port: Int, host: String, handler: Handler[AsyncResult[DatagramSocket]]): DatagramSocket

    Write the given String to the io.vertx.scala.core.net.SocketAddress using the given encoding.

    Write the given String to the io.vertx.scala.core.net.SocketAddress using the given encoding. The will be notified once the write completes.

    str

      the String to write

    enc

      the charset used for encoding

    port

      the host port of the remote peer

    host

      the host address of the remote peer

    handler

      the scala-function to notify once the write completes.

    returns

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

37.  def send(str: String, port: Int, host: String, handler: Handler[AsyncResult[DatagramSocket]]): DatagramSocket

    Write the given String to the io.vertx.scala.core.net.SocketAddress using UTF8 encoding.

    Write the given String to the io.vertx.scala.core.net.SocketAddress using UTF8 encoding. The will be notified once the write completes.

    str

      the String to write

    port

      the host port of the remote peer

    host

      the host address of the remote peer

    handler

      the scala-function to notify once the write completes.

    returns

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

38.  def send(packet: Buffer, port: Int, host: String, handler: Handler[AsyncResult[DatagramSocket]]): DatagramSocket

    Write the given io.vertx.scala.core.buffer.Buffer to the io.vertx.scala.core.net.SocketAddress.

    Write the given io.vertx.scala.core.buffer.Buffer to the io.vertx.scala.core.net.SocketAddress. The scala-function will be notified once the write completes.

    packet

      the io.vertx.scala.core.buffer.Buffer to write

    port

      the host port of the remote peer

    host

      the host address of the remote peer

    handler

      the scala-function to notify once the write completes.

    returns

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

39.  def sendFuture(str: String, enc: String, port: Int, host: String): scala.concurrent.Future[DatagramSocket]

    Like send but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

40.  def sendFuture(str: String, port: Int, host: String): scala.concurrent.Future[DatagramSocket]

    Like send but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

41.  def sendFuture(packet: Buffer, port: Int, host: String): scala.concurrent.Future[DatagramSocket]

    Like send but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

42.  def sender(port: Int, host: String): WriteStream[Buffer]

    Returns a `WriteStream<Buffer>` able to send to the io.vertx.scala.core.net.SocketAddress.

    Returns a `WriteStream<Buffer>` able to send to the io.vertx.scala.core.net.SocketAddress.

    port

      the port of the remote peer

    host

      the host address of the remote peer

    returns

      the write stream for sending packets

43.  final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
      AnyRef
44.  def toString(): String
    Definition Classes
      AnyRef → Any
45.  def unlistenMulticastGroup(multicastAddress: String, networkInterface: String, source: Option[String], handler: Handler[AsyncResult[DatagramSocket]]): DatagramSocket

    Leaves a multicast group and stops listening for packets send to it on the given network interface.

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

    multicastAddress

      the address of the multicast group to join

    networkInterface

      the network interface on which to listen for packets.

    source

      the address of the source for which we will listen for multicast packets

    handler

      the handler to notify once the operation completes

    returns

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

46.  def unlistenMulticastGroup(multicastAddress: String, handler: Handler[AsyncResult[DatagramSocket]]): DatagramSocket

    Leaves a multicast group and stops listening for packets send to it.

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

    multicastAddress

      the address of the multicast group to leave

    handler

      then handler to notify once the operation completes

    returns

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

47.  def unlistenMulticastGroupFuture(multicastAddress: String, networkInterface: String, source: Option[String]): scala.concurrent.Future[DatagramSocket]

    Like unlistenMulticastGroup but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

48.  def unlistenMulticastGroupFuture(multicastAddress: String): scala.concurrent.Future[DatagramSocket]

    Like unlistenMulticastGroup but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

49.  final def wait(): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
50.  final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
51.  final def wait(arg0: Long): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )

### Inherited from Measured

### Inherited from ReadStream[DatagramPacket]

### Inherited from StreamBase

### Inherited from AnyRef

### Inherited from Any

### Ungrouped