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 |
|---|---|
DatagramSocket |
blockMulticastGroup(String multicastAddress,
String sourceToBlock,
Handler<AsyncResult<DatagramSocket>> handler)
Block the given address for the given multicast address and notifies the
Handler once
the operation completes. |
DatagramSocket |
blockMulticastGroup(String multicastAddress,
String networkInterface,
String sourceToBlock,
Handler<AsyncResult<DatagramSocket>> handler)
Block the given address for the given multicast address on the given network interface and notifies
the
Handler once the operation completes. |
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.
|
DatagramSocket |
listen(int port,
String host,
Handler<AsyncResult<DatagramSocket>> handler)
Start listening on the given port and host.
|
DatagramSocket |
listenMulticastGroup(String multicastAddress,
Handler<AsyncResult<DatagramSocket>> handler)
Joins a multicast group and listens for packets send to it.
|
DatagramSocket |
listenMulticastGroup(String multicastAddress,
String networkInterface,
String source,
Handler<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()
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. |
DatagramSocket |
send(Buffer packet,
int port,
String host,
Handler<AsyncResult<DatagramSocket>> handler)
Write the given
Buffer to the SocketAddress. |
DatagramSocket |
send(String str,
int port,
String host,
Handler<AsyncResult<DatagramSocket>> handler)
Write the given
String to the SocketAddress using UTF8 encoding. |
DatagramSocket |
send(String str,
String enc,
int port,
String host,
Handler<AsyncResult<DatagramSocket>> handler)
Write the given
String to the SocketAddress using the given encoding. |
WriteStream<Buffer> |
sender(int port,
String host)
|
DatagramSocket |
unlistenMulticastGroup(String multicastAddress,
Handler<AsyncResult<DatagramSocket>> handler)
Leaves a multicast group and stops listening for packets send to it.
|
DatagramSocket |
unlistenMulticastGroup(String multicastAddress,
String networkInterface,
String source,
Handler<AsyncResult<DatagramSocket>> 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<DatagramSocket>> handler)
WriteStream<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<DatagramSocket>> handler)
String to the SocketAddress using UTF8 encoding.
The Handler will be notified once the write completes.DatagramSocket send(String str, String enc, int port, String host, Handler<AsyncResult<DatagramSocket>> handler)
String to the SocketAddress using the given encoding.
The Handler will be notified once the write completes.void close(Handler<AsyncResult<Void>> handler)
DatagramSocket implementation asynchronous
and notifies the handler once done.handler - the handler to notify once completevoid close()
DatagramSocket. The close itself is asynchronous.SocketAddress localAddress()
SocketAddress to which
this DatagramSocket is bound.DatagramSocket listenMulticastGroup(String multicastAddress, Handler<AsyncResult<DatagramSocket>> handler)
Handler is notified once the operation completes.multicastAddress - the address of the multicast group to joinhandler - then handler to notify once the operation completesDatagramSocket listenMulticastGroup(String multicastAddress, String networkInterface, String source, Handler<AsyncResult<DatagramSocket>> 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 completesDatagramSocket unlistenMulticastGroup(String multicastAddress, Handler<AsyncResult<DatagramSocket>> handler)
Handler is notified once the operation completes.multicastAddress - the address of the multicast group to leavehandler - then handler to notify once the operation completesDatagramSocket unlistenMulticastGroup(String multicastAddress, String networkInterface, String source, Handler<AsyncResult<DatagramSocket>> 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 completesDatagramSocket blockMulticastGroup(String multicastAddress, String sourceToBlock, Handler<AsyncResult<DatagramSocket>> 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 completesDatagramSocket blockMulticastGroup(String multicastAddress, String networkInterface, String sourceToBlock, Handler<AsyncResult<DatagramSocket>> 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 completesDatagramSocket 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 listeningDatagramSocket 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 © 2023 Eclipse. All rights reserved.