public interface DatagramSocket extends ReadStream<DatagramPacket>, Measured
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.
| Modifier and Type | Method and Description |
|---|---|
Future<Void> |
blockMulticastGroup(String multicastAddress,
String sourceToBlock)
Like
blockMulticastGroup(String, String, Handler) but returns a Future of the asynchronous result |
DatagramSocket |
blockMulticastGroup(String multicastAddress,
String sourceToBlock,
Handler<AsyncResult<Void>> handler)
Block the given address for the given multicast address and notifies the
Handler once
the operation completes. |
Future<Void> |
blockMulticastGroup(String multicastAddress,
String networkInterface,
String sourceToBlock)
Like
blockMulticastGroup(String, String, String, Handler) but returns a Future of the asynchronous result |
DatagramSocket |
blockMulticastGroup(String multicastAddress,
String networkInterface,
String sourceToBlock,
Handler<AsyncResult<Void>> handler)
Block the given address for the given multicast address on the given network interface and notifies
the
Handler once the operation completes. |
Future<Void> |
close()
Closes the
DatagramSocket. |
void |
close(Handler<AsyncResult<Void>> handler)
Closes the
DatagramSocket implementation asynchronous
and notifies the handler once done. |
DatagramSocket |
endHandler(Handler<Void> endHandler)
Set an end handler.
|
DatagramSocket |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.
|
DatagramSocket |
fetch(long amount)
Fetch the specified
amount of elements. |
DatagramSocket |
handler(Handler<DatagramPacket> handler)
Set a data handler.
|
Future<DatagramSocket> |
listen(int port,
String host)
Like
listen(int, String, Handler) but returns a Future of the asynchronous result |
DatagramSocket |
listen(int port,
String host,
Handler<AsyncResult<DatagramSocket>> handler)
Start listening on the given port and host.
|
Future<Void> |
listenMulticastGroup(String multicastAddress)
Like
listenMulticastGroup(String, Handler) but returns a Future of the asynchronous result |
DatagramSocket |
listenMulticastGroup(String multicastAddress,
Handler<AsyncResult<Void>> handler)
Joins a multicast group and listens for packets send to it.
|
Future<Void> |
listenMulticastGroup(String multicastAddress,
String networkInterface,
String source)
Like
listenMulticastGroup(String, String, String, Handler) but returns a Future of the asynchronous result |
DatagramSocket |
listenMulticastGroup(String multicastAddress,
String networkInterface,
String source,
Handler<AsyncResult<Void>> 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()
Pause the
ReadStream, it sets the buffer in fetch mode and clears the actual demand. |
DatagramSocket |
resume()
Resume reading, and sets the buffer in
flowing mode. |
Future<Void> |
send(Buffer packet,
int port,
String host)
Like
send(Buffer, int, String, Handler) but returns a Future of the asynchronous result |
DatagramSocket |
send(Buffer packet,
int port,
String host,
Handler<AsyncResult<Void>> handler)
Write the given
Buffer to the SocketAddress. |
Future<Void> |
send(String str,
int port,
String host)
Like
send(String, int, String, Handler) but returns a Future of the asynchronous result |
DatagramSocket |
send(String str,
int port,
String host,
Handler<AsyncResult<Void>> handler)
Write the given
String to the SocketAddress using UTF8 encoding. |
Future<Void> |
send(String str,
String enc,
int port,
String host)
Like
send(String, String, int, String, Handler) but returns a Future of the asynchronous result |
DatagramSocket |
send(String str,
String enc,
int port,
String host,
Handler<AsyncResult<Void>> handler)
Write the given
String to the SocketAddress using the given encoding. |
WriteStream<Buffer> |
sender(int port,
String host)
|
Future<Void> |
unlistenMulticastGroup(String multicastAddress)
Like
unlistenMulticastGroup(String, Handler) but returns a Future of the asynchronous result |
DatagramSocket |
unlistenMulticastGroup(String multicastAddress,
Handler<AsyncResult<Void>> handler)
Leaves a multicast group and stops listening for packets send to it.
|
Future<Void> |
unlistenMulticastGroup(String multicastAddress,
String networkInterface,
String source)
Like
unlistenMulticastGroup(String, String, String, Handler) but returns a Future of the asynchronous result |
DatagramSocket |
unlistenMulticastGroup(String multicastAddress,
String networkInterface,
String source,
Handler<AsyncResult<Void>> handler)
Leaves a multicast group and stops listening for packets send to it on the given network interface.
|
pipe, pipeTo, pipeToisMetricsEnabledDatagramSocket send(Buffer packet, int port, String host, Handler<AsyncResult<Void>> handler)
Future<Void> send(Buffer packet, int port, String host)
send(Buffer, int, String, Handler) but returns a Future of the asynchronous resultWriteStream<Buffer> sender(int port, String host)
port - the port of the remote peerhost - the host address of the remote peerDatagramSocket send(String str, int port, String host, Handler<AsyncResult<Void>> handler)
String to the SocketAddress using UTF8 encoding.
The Handler will be notified once the write completes.Future<Void> send(String str, int port, String host)
send(String, int, String, Handler) but returns a Future of the asynchronous resultDatagramSocket send(String str, String enc, int port, String host, Handler<AsyncResult<Void>> handler)
String to the SocketAddress using the given encoding.
The Handler will be notified once the write completes.Future<Void> send(String str, String enc, int port, String host)
send(String, String, int, String, Handler) but returns a Future of the asynchronous resultvoid close(Handler<AsyncResult<Void>> handler)
DatagramSocket implementation asynchronous
and notifies the handler once done.handler - the handler to notify once completeFuture<Void> close()
DatagramSocket. The close itself is asynchronous.SocketAddress localAddress()
SocketAddress to which
this DatagramSocket is bound.DatagramSocket listenMulticastGroup(String multicastAddress, Handler<AsyncResult<Void>> handler)
Handler is notified once the operation completes.multicastAddress - the address of the multicast group to joinhandler - then handler to notify once the operation completesFuture<Void> listenMulticastGroup(String multicastAddress)
listenMulticastGroup(String, Handler) but returns a Future of the asynchronous resultDatagramSocket listenMulticastGroup(String multicastAddress, String networkInterface, String source, Handler<AsyncResult<Void>> handler)
Handler 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 completesFuture<Void> listenMulticastGroup(String multicastAddress, String networkInterface, String source)
listenMulticastGroup(String, String, String, Handler) but returns a Future of the asynchronous resultDatagramSocket unlistenMulticastGroup(String multicastAddress, Handler<AsyncResult<Void>> handler)
Handler is notified once the operation completes.multicastAddress - the address of the multicast group to leavehandler - then handler to notify once the operation completesFuture<Void> unlistenMulticastGroup(String multicastAddress)
unlistenMulticastGroup(String, Handler) but returns a Future of the asynchronous resultDatagramSocket unlistenMulticastGroup(String multicastAddress, String networkInterface, String source, Handler<AsyncResult<Void>> handler)
Handler 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 completesFuture<Void> unlistenMulticastGroup(String multicastAddress, String networkInterface, String source)
unlistenMulticastGroup(String, String, String, Handler) but returns a Future of the asynchronous resultDatagramSocket blockMulticastGroup(String multicastAddress, String sourceToBlock, Handler<AsyncResult<Void>> handler)
Handler 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 completesFuture<Void> blockMulticastGroup(String multicastAddress, String sourceToBlock)
blockMulticastGroup(String, String, Handler) but returns a Future of the asynchronous resultDatagramSocket blockMulticastGroup(String multicastAddress, String networkInterface, String sourceToBlock, Handler<AsyncResult<Void>> handler)
Handler 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 completesFuture<Void> blockMulticastGroup(String multicastAddress, String networkInterface, String sourceToBlock)
blockMulticastGroup(String, String, String, Handler) but returns a Future of the asynchronous resultDatagramSocket listen(int port, String host, Handler<AsyncResult<DatagramSocket>> handler)
port - the port to listen onhost - the host to listen onhandler - the handler will be called when listeningFuture<DatagramSocket> listen(int port, String host)
listen(int, String, Handler) but returns a Future of the asynchronous resultDatagramSocket pause()
ReadStreamReadStream, it sets the buffer in fetch mode and clears the actual demand.
While it's paused, no data will be sent to the data handler.
pause in interface ReadStream<DatagramPacket>DatagramSocket resume()
ReadStreamflowing mode.
If the ReadStream has been paused, reading will recommence on it.resume in interface ReadStream<DatagramPacket>DatagramSocket fetch(long amount)
ReadStreamamount of elements. If the ReadStream has been paused, reading will
recommence with the specified amount of items, otherwise the specified amount will
be added to the current stream demand.fetch in interface ReadStream<DatagramPacket>DatagramSocket endHandler(Handler<Void> endHandler)
ReadStreamendHandler in interface ReadStream<DatagramPacket>DatagramSocket handler(Handler<DatagramPacket> handler)
ReadStreamhandler in interface ReadStream<DatagramPacket>DatagramSocket exceptionHandler(Handler<Throwable> handler)
ReadStreamexceptionHandler in interface ReadStream<DatagramPacket>exceptionHandler in interface StreamBasehandler - the exception handlerCopyright © 2022 Eclipse. All rights reserved.