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.
- Alphabetic
- By Inheritance
- DatagramSocket
- Measured
- ReadStream
- StreamBase
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new DatagramSocket(_asJava: AnyRef)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
asJava: AnyRef
- Definition Classes
- DatagramSocket → Measured → ReadStream → StreamBase
-
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. * @param 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
-
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. * @param 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
-
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.
-
def
blockMulticastGroupFuture(multicastAddress: String, sourceToBlock: String): scala.concurrent.Future[DatagramSocket]
Like blockMulticastGroup but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
close(): Unit
Closes the io.vertx.scala.core.datagram.DatagramSocket.
Closes the io.vertx.scala.core.datagram.DatagramSocket. The close itself is asynchronous.
-
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. * @param handler the handler to notify once complete
-
def
closeFuture(): scala.concurrent.Future[Unit]
Like close but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
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. * @return a reference to this, so the API can be used fluently
- Definition Classes
- DatagramSocket → ReadStream
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
exceptionHandler(handler: Handler[Throwable]): DatagramSocket
Set an exception handler on the read stream.
Set an exception handler on the read stream. * @param handler the exception handler
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- DatagramSocket → ReadStream → StreamBase
-
def
fetch(amount: Long): DatagramSocket
Fetch the specified
amount
of elements.Fetch the specified
amount
of elements. If theReadStream
has been paused, reading will recommence with the specifiedamount
of items, otherwise the specifiedamount
will be added to the current stream demand. * @return a reference to this, so the API can be used fluently- Definition Classes
- DatagramSocket → ReadStream
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
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. * @return a reference to this, so the API can be used fluently
- Definition Classes
- DatagramSocket → ReadStream
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isMetricsEnabled(): Boolean
Whether the metrics are enabled for this measured object * @return
true
if metrics are enabledWhether the metrics are enabled for this measured object * @return
true
if metrics are enabled- Definition Classes
- DatagramSocket → Measured
-
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. * @param 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
-
def
listenFuture(port: Int, host: String): scala.concurrent.Future[DatagramSocket]
Like listen but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
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. * @param 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
-
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. * @param 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
-
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.
-
def
listenMulticastGroupFuture(multicastAddress: String): scala.concurrent.Future[DatagramSocket]
Like listenMulticastGroup but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
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. * @return the socket address
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
pause(): DatagramSocket
Pause the
ReadStream
, it sets the buffer infetch
mode and clears the actual demand.Pause the
ReadStream
, it sets the buffer infetch
mode and clears the actual demand.While it's paused, no data will be sent to the data
handler
. * @return a reference to this, so the API can be used fluently- Definition Classes
- DatagramSocket → ReadStream
-
def
resume(): DatagramSocket
Resume reading, and sets the buffer in
flowing
mode.Resume reading, and sets the buffer in
flowing
mode.If the
ReadStream
has been paused, reading will recommence on it. * @return a reference to this, so the API can be used fluently- Definition Classes
- DatagramSocket → ReadStream
-
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. * @param 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
-
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. * @param 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
-
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. * @param 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
-
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.
-
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.
-
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.
-
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. * @param port the port of the remote peer- host
the host address of the remote peer
- returns
the write stream for sending packets
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
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. * @param 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
-
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. * @param 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
-
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.
-
def
unlistenMulticastGroupFuture(multicastAddress: String): scala.concurrent.Future[DatagramSocket]
Like unlistenMulticastGroup but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )