@groovy.transform.CompileStatic class DatagramSocket extends java.lang.Object
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.
Constructor and description |
---|
DatagramSocket
(java.lang.Object delegate) |
Type | Name and description |
---|---|
DatagramSocket |
blockMulticastGroup(java.lang.String multicastAddress, java.lang.String sourceToBlock, io.vertx.core.Handler<io.vertx.core.AsyncResult<DatagramSocket>> handler) Block the given address for the given multicast address and notifies the once the operation completes. |
DatagramSocket |
blockMulticastGroup(java.lang.String multicastAddress, java.lang.String networkInterface, java.lang.String sourceToBlock, io.vertx.core.Handler<io.vertx.core.AsyncResult<DatagramSocket>> handler) Block the given address for the given multicast address on the given network interface and notifies the once the operation completes. |
void |
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Closes the DatagramSocket implementation asynchronous and notifies the handler once done. |
void |
close() Closes the DatagramSocket. |
DatagramSocket |
endHandler(io.vertx.core.Handler<java.lang.Void> endHandler) |
DatagramSocket |
exceptionHandler(io.vertx.core.Handler<java.lang.Throwable> handler) |
java.lang.Object |
getDelegate() |
DatagramSocket |
handler(io.vertx.core.Handler<DatagramPacket> handler) |
boolean |
isMetricsEnabled() Whether the metrics are enabled for this measured object |
DatagramSocket |
listen(int port, java.lang.String host, io.vertx.core.Handler<io.vertx.core.AsyncResult<DatagramSocket>> handler) Start listening on the given port and host. |
DatagramSocket |
listenMulticastGroup(java.lang.String multicastAddress, io.vertx.core.Handler<io.vertx.core.AsyncResult<DatagramSocket>> handler) Joins a multicast group and listens for packets send to it. |
DatagramSocket |
listenMulticastGroup(java.lang.String multicastAddress, java.lang.String networkInterface, java.lang.String source, io.vertx.core.Handler<io.vertx.core.AsyncResult<DatagramSocket>> handler) Joins a multicast group and listens for packets send to it on the given network interface. |
SocketAddress |
localAddress() Return the SocketAddress to which this DatagramSocket is bound. |
DatagramSocket |
pause() |
DatagramSocket |
resume() |
DatagramSocket |
send(Buffer packet, int port, java.lang.String host, io.vertx.core.Handler<io.vertx.core.AsyncResult<DatagramSocket>> handler) Write the given Buffer to the SocketAddress. |
DatagramSocket |
send(java.lang.String str, int port, java.lang.String host, io.vertx.core.Handler<io.vertx.core.AsyncResult<DatagramSocket>> handler) Write the given java.lang.String to the SocketAddress using UTF8 encoding. |
DatagramSocket |
send(java.lang.String str, java.lang.String enc, int port, java.lang.String host, io.vertx.core.Handler<io.vertx.core.AsyncResult<DatagramSocket>> handler) Write the given java.lang.String to the SocketAddress using the given encoding. |
PacketWritestream |
sender(int port, java.lang.String host) Returns a PacketWritestream able to send to the SocketAddress. |
DatagramSocket |
unlistenMulticastGroup(java.lang.String multicastAddress, io.vertx.core.Handler<io.vertx.core.AsyncResult<DatagramSocket>> handler) Leaves a multicast group and stops listening for packets send to it. |
DatagramSocket |
unlistenMulticastGroup(java.lang.String multicastAddress, java.lang.String networkInterface, java.lang.String source, io.vertx.core.Handler<io.vertx.core.AsyncResult<DatagramSocket>> handler) Leaves a multicast group and stops listening for packets send to it on the given network interface. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
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 addresssourceToBlock
- 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 completesBlock 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 addressnetworkInterface
- 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 completesCloses the DatagramSocket implementation asynchronous and notifies the handler once done.
handler
- the handler to notify once completeCloses the DatagramSocket. The close itself is asynchronous.
Whether the metrics are enabled for this measured object
Start listening on the given port and host. The handler will be called when the socket is listening.
port
- the port to listen onhost
- the host to listen onhandler
- the handler will be called when listeningJoins 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 joinhandler
- then handler to notify once the operation completesJoins 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 joinnetworkInterface
- the network interface on which to listen for packets.source
- the address of the source for which we will listen for multicast packetshandler
- then handler to notify once the operation completesReturn the SocketAddress to which this DatagramSocket is bound.
Write the given Buffer to the SocketAddress. The io.vertx.groovy.core.Handler will be notified once the write completes.
packet
- the Buffer to writeport
- the host port of the remote peerhost
- the host address of the remote peerhandler
- the io.vertx.groovy.core.Handler to notify once the write completes.Write the given java.lang.String to the SocketAddress using UTF8 encoding. The will be notified once the write completes.
str
- the java.lang.String to writeport
- the host port of the remote peerhost
- the host address of the remote peerhandler
- the io.vertx.groovy.core.Handler to notify once the write completes.Write the given java.lang.String to the SocketAddress using the given encoding. The will be notified once the write completes.
str
- the java.lang.String to writeenc
- the charset used for encodingport
- the host port of the remote peerhost
- the host address of the remote peerhandler
- the io.vertx.groovy.core.Handler to notify once the write completes.Returns a PacketWritestream able to send to the SocketAddress.
port
- the port of the remote peerhost
- the host address of the remote peerLeaves 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 leavehandler
- then handler to notify once the operation completesLeaves 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 joinnetworkInterface
- the network interface on which to listen for packets.source
- the address of the source for which we will listen for multicast packetshandler
- the handler to notify once the operation completes