public interface DatagramSocket extends DrainSupport<DatagramSocket>, NetworkSupport<DatagramSocket>, ReadSupport<DatagramSocket,DatagramPacket>
DatagramPacket's to remote Datagram servers and receive DatagramPackets .
Usually you use a Datragram Client 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.| Modifier and Type | Method and Description |
|---|---|
DatagramSocket |
blockMulticastGroup(java.lang.String multicastAddress,
java.lang.String sourceToBlock,
Handler<AsyncResult<DatagramSocket>> handler)
Block the given sourceToBlock address for the given multicastAddress and notifies the
Handler once
the operation completes. |
DatagramSocket |
blockMulticastGroup(java.lang.String multicastAddress,
java.lang.String networkInterface,
java.lang.String sourceToBlock,
Handler<AsyncResult<DatagramSocket>> handler)
Block the given sourceToBlock address for the given multicastAddress on the given network interface and notifies
the
Handler once the operation completes. |
void |
close()
Close the
DatagramSocket implementation asynchronous. |
void |
close(Handler<AsyncResult<java.lang.Void>> handler)
Close the
DatagramSocket implementation asynchronous and notifies the handler once done. |
java.lang.String |
getMulticastNetworkInterface()
Gets the
StandardSocketOptions.IP_MULTICAST_IF option. |
int |
getMulticastTimeToLive()
Gets the
StandardSocketOptions.IP_MULTICAST_TTL option. |
boolean |
isBroadcast()
Gets the
StandardSocketOptions.SO_BROADCAST option. |
boolean |
isMulticastLoopbackMode()
Gets the
StandardSocketOptions.IP_MULTICAST_LOOP option. |
DatagramSocket |
listen(java.net.InetSocketAddress local,
Handler<AsyncResult<DatagramSocket>> handler)
Makes this
DatagramSocket listen to the given InetSocketAddress. |
DatagramSocket |
listen(int port,
Handler<AsyncResult<DatagramSocket>> handler) |
DatagramSocket |
listen(java.lang.String address,
int port,
Handler<AsyncResult<DatagramSocket>> handler) |
DatagramSocket |
listenMulticastGroup(java.lang.String multicastAddress,
Handler<AsyncResult<DatagramSocket>> handler)
Joins a multicast group and so start listen for packets send to it.
|
DatagramSocket |
listenMulticastGroup(java.lang.String multicastAddress,
java.lang.String networkInterface,
java.lang.String source,
Handler<AsyncResult<DatagramSocket>> handler)
Joins a multicast group and so start listen for packets send to it on the given network interface.
|
java.net.InetSocketAddress |
localAddress()
Return the
InetSocketAddress to which this DatagramSocket is bound too. |
DatagramSocket |
send(Buffer packet,
java.lang.String host,
int port,
Handler<AsyncResult<DatagramSocket>> handler)
Write the given
Buffer to the InetSocketAddress. |
DatagramSocket |
send(java.lang.String str,
java.lang.String host,
int port,
Handler<AsyncResult<DatagramSocket>> handler)
Write the given
String to the InetSocketAddress using UTF8 encoding. |
DatagramSocket |
send(java.lang.String str,
java.lang.String enc,
java.lang.String host,
int port,
Handler<AsyncResult<DatagramSocket>> handler)
Write the given
String to the InetSocketAddress using the given encoding. |
DatagramSocket |
setBroadcast(boolean broadcast)
Sets the
StandardSocketOptions.SO_BROADCAST option. |
DatagramSocket |
setMulticastLoopbackMode(boolean loopbackModeDisabled)
Sets the
StandardSocketOptions.IP_MULTICAST_LOOP option. |
DatagramSocket |
setMulticastNetworkInterface(java.lang.String iface)
Sets the
StandardSocketOptions.IP_MULTICAST_IF option. |
DatagramSocket |
setMulticastTimeToLive(int ttl)
Sets the
StandardSocketOptions.IP_MULTICAST_TTL option. |
DatagramSocket |
unlistenMulticastGroup(java.lang.String multicastAddress,
Handler<AsyncResult<DatagramSocket>> handler)
Leaves a multicast group and so stop listen for packets send to it.
|
DatagramSocket |
unlistenMulticastGroup(java.lang.String multicastAddress,
java.lang.String networkInterface,
java.lang.String source,
Handler<AsyncResult<DatagramSocket>> handler)
Leaves a multicast group and so stop listen for packets send to it on the given network interface.
|
drainHandler, setWriteQueueMaxSize, writeQueueFullgetReceiveBufferSize, getSendBufferSize, getTrafficClass, isReuseAddress, setReceiveBufferSize, setReuseAddress, setSendBufferSize, setTrafficClassdataHandler, pause, resumeexceptionHandlerDatagramSocket send(Buffer packet, java.lang.String host, int port, Handler<AsyncResult<DatagramSocket>> handler)
DatagramSocket send(java.lang.String str, java.lang.String host, int port, Handler<AsyncResult<DatagramSocket>> handler)
String to the InetSocketAddress using UTF8 encoding. The Handler will be notified once the
write completes.str - the String to writehost - the host address of the remote peerport - the host port of the remote peerhandler - the Handler to notify once the write completes.DatagramSocket send(java.lang.String str, java.lang.String enc, java.lang.String host, int port, Handler<AsyncResult<DatagramSocket>> handler)
String to the InetSocketAddress using the given encoding. The Handler will be notified once the
write completes.str - the String to writeenc - the charset used for encodinghost - the host address of the remote peerport - the host port of the remote peerhandler - the Handler to notify once the write completes.boolean isBroadcast()
StandardSocketOptions.SO_BROADCAST option.DatagramSocket setBroadcast(boolean broadcast)
StandardSocketOptions.SO_BROADCAST option.boolean isMulticastLoopbackMode()
StandardSocketOptions.IP_MULTICAST_LOOP option.true if and only if the loopback mode has been disabledDatagramSocket setMulticastLoopbackMode(boolean loopbackModeDisabled)
StandardSocketOptions.IP_MULTICAST_LOOP option.loopbackModeDisabled - true if and only if the loopback mode has been disabledint getMulticastTimeToLive()
StandardSocketOptions.IP_MULTICAST_TTL option.DatagramSocket setMulticastTimeToLive(int ttl)
StandardSocketOptions.IP_MULTICAST_TTL option.java.lang.String getMulticastNetworkInterface()
StandardSocketOptions.IP_MULTICAST_IF option.DatagramSocket setMulticastNetworkInterface(java.lang.String iface)
StandardSocketOptions.IP_MULTICAST_IF option.void close(Handler<AsyncResult<java.lang.Void>> handler)
DatagramSocket implementation asynchronous and notifies the handler once done.void close()
DatagramSocket implementation asynchronous.java.net.InetSocketAddress localAddress()
InetSocketAddress to which this DatagramSocket is bound too.DatagramSocket listenMulticastGroup(java.lang.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(java.lang.String multicastAddress, java.lang.String networkInterface, java.lang.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 mulicast packetshandler - then handler to notify once the operation completesDatagramSocket unlistenMulticastGroup(java.lang.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(java.lang.String multicastAddress, java.lang.String networkInterface, java.lang.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 mulicast packetshandler - then handler to notify once the operation completesDatagramSocket blockMulticastGroup(java.lang.String multicastAddress, java.lang.String sourceToBlock, Handler<AsyncResult<DatagramSocket>> handler)
Handler once
the operation completes.multicastAddress - the address for which you want to block the sourceToBlocksourceToBlock - the source address which should be blocked. You will not receive an multicast packets
for it anymore.handler - then handler to notify once the operation completesDatagramSocket blockMulticastGroup(java.lang.String multicastAddress, java.lang.String networkInterface, java.lang.String sourceToBlock, Handler<AsyncResult<DatagramSocket>> handler)
Handler once the operation completes.multicastAddress - the address for which you want to block the sourceToBlocknetworkInterface - the network interface on which the blocking should accour.sourceToBlock - the source address which should be blocked. You will not receive an multicast packets
for it anymore.handler - then handler to notify once the operation completesDatagramSocket listen(java.lang.String address, int port, Handler<AsyncResult<DatagramSocket>> handler)
DatagramSocket listen(int port, Handler<AsyncResult<DatagramSocket>> handler)
DatagramSocket listen(java.net.InetSocketAddress local, Handler<AsyncResult<DatagramSocket>> handler)
DatagramSocket listen to the given InetSocketAddress. Once the operation completes
the Handler is notified.local - the InetSocketAddress on which the DatagramSocket will listen for DatagramPackets.handler - the Handler to notify once the operation completes