public class DatagramSocket extends Object implements 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.
NOTE: This class has been automatically generated from theoriginal non RX-ified interface using Vert.x codegen.| Constructor and Description |
|---|
DatagramSocket(DatagramSocket delegate) |
| 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 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 once the operation completes.
|
rx.Observable<DatagramSocket> |
blockMulticastGroupObservable(String multicastAddress,
String sourceToBlock)
Block the given address for the given multicast address and notifies the once
the operation completes.
|
rx.Observable<DatagramSocket> |
blockMulticastGroupObservable(String multicastAddress,
String networkInterface,
String sourceToBlock)
Block the given address for the given multicast address on the given network interface and notifies
the 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. |
rx.Observable<Void> |
closeObservable()
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.
|
Object |
getDelegate() |
DatagramSocket |
handler(Handler<DatagramPacket> handler)
Set a data handler.
|
boolean |
isMetricsEnabled()
Whether the metrics are enabled for this measured object
|
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.
|
rx.Observable<DatagramSocket> |
listenMulticastGroupObservable(String multicastAddress)
Joins a multicast group and listens for packets send to it.
|
rx.Observable<DatagramSocket> |
listenMulticastGroupObservable(String multicastAddress,
String networkInterface,
String source)
Joins a multicast group and listens for packets send to it on the given network interface.
|
rx.Observable<DatagramSocket> |
listenObservable(int port,
String host)
Start listening on the given port and host.
|
SocketAddress |
localAddress()
Return the
SocketAddress to which
this DatagramSocket is bound. |
static DatagramSocket |
newInstance(DatagramSocket arg) |
DatagramSocket |
pause()
Pause the
ReadSupport. |
DatagramSocket |
resume()
Resume reading.
|
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. |
PacketWritestream |
sender(int port,
String host)
Returns a
PacketWritestream able to send to the
SocketAddress. |
rx.Observable<DatagramSocket> |
sendObservable(Buffer packet,
int port,
String host)
Write the given
Buffer to the SocketAddress. |
rx.Observable<DatagramSocket> |
sendObservable(String str,
int port,
String host)
Write the given
String to the SocketAddress using UTF8 encoding. |
rx.Observable<DatagramSocket> |
sendObservable(String str,
String enc,
int port,
String host)
Write the given
String to the SocketAddress using the given encoding. |
rx.Observable<DatagramPacket> |
toObservable() |
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.
|
rx.Observable<DatagramSocket> |
unlistenMulticastGroupObservable(String multicastAddress)
Leaves a multicast group and stops listening for packets send to it.
|
rx.Observable<DatagramSocket> |
unlistenMulticastGroupObservable(String multicastAddress,
String networkInterface,
String source)
Leaves a multicast group and stops listening for packets send to it on the given network interface.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitnewInstancenewInstancenewInstancepublic DatagramSocket(DatagramSocket delegate)
public Object getDelegate()
getDelegate in interface MeasuredgetDelegate in interface ReadStream<DatagramPacket>getDelegate in interface StreamBasepublic rx.Observable<DatagramPacket> toObservable()
toObservable in interface ReadStream<DatagramPacket>public boolean isMetricsEnabled()
isMetricsEnabled in interface Measuredpublic DatagramSocket send(Buffer packet, int port, String host, Handler<AsyncResult<DatagramSocket>> handler)
public rx.Observable<DatagramSocket> sendObservable(Buffer packet, int port, String host)
Buffer to the SocketAddress.
The io.vertx.rxjava.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 peerpublic PacketWritestream sender(int port, String host)
PacketWritestream able to send to the
SocketAddress.port - the port of the remote peerhost - the host address of the remote peerpublic DatagramSocket send(String str, int port, String host, Handler<AsyncResult<DatagramSocket>> handler)
String to the SocketAddress using UTF8 encoding.
The will be notified once the write completes.str - the String to writeport - the host port of the remote peerhost - the host address of the remote peerhandler - the io.vertx.rxjava.core.Handler to notify once the write completes.public rx.Observable<DatagramSocket> sendObservable(String str, int port, String host)
String to the SocketAddress using UTF8 encoding.
The will be notified once the write completes.str - the String to writeport - the host port of the remote peerhost - the host address of the remote peerpublic DatagramSocket send(String str, String enc, int port, String host, Handler<AsyncResult<DatagramSocket>> handler)
String to the SocketAddress using the given encoding.
The will be notified once the write completes.public rx.Observable<DatagramSocket> sendObservable(String str, String enc, int port, String host)
String to the SocketAddress using the given encoding.
The will be notified once the write completes.str - the String to writeenc - the charset used for encodingport - the host port of the remote peerhost - the host address of the remote peerpublic void close(Handler<AsyncResult<Void>> handler)
DatagramSocket implementation asynchronous
and notifies the handler once done.handler - the handler to notify once completepublic rx.Observable<Void> closeObservable()
DatagramSocket implementation asynchronous
and notifies the handler once done.public void close()
DatagramSocket. The close itself is asynchronous.public SocketAddress localAddress()
SocketAddress to which
this DatagramSocket is bound.public DatagramSocket listenMulticastGroup(String multicastAddress, Handler<AsyncResult<DatagramSocket>> handler)
multicastAddress - the address of the multicast group to joinhandler - then handler to notify once the operation completespublic rx.Observable<DatagramSocket> listenMulticastGroupObservable(String multicastAddress)
multicastAddress - the address of the multicast group to joinpublic DatagramSocket listenMulticastGroup(String multicastAddress, String networkInterface, String source, Handler<AsyncResult<DatagramSocket>> handler)
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 completespublic rx.Observable<DatagramSocket> listenMulticastGroupObservable(String multicastAddress, String networkInterface, String source)
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 packetspublic DatagramSocket unlistenMulticastGroup(String multicastAddress, Handler<AsyncResult<DatagramSocket>> handler)
multicastAddress - the address of the multicast group to leavehandler - then handler to notify once the operation completespublic rx.Observable<DatagramSocket> unlistenMulticastGroupObservable(String multicastAddress)
multicastAddress - the address of the multicast group to leavepublic DatagramSocket unlistenMulticastGroup(String multicastAddress, String networkInterface, String source, Handler<AsyncResult<DatagramSocket>> handler)
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 completespublic rx.Observable<DatagramSocket> unlistenMulticastGroupObservable(String multicastAddress, String networkInterface, String source)
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 packetspublic DatagramSocket blockMulticastGroup(String multicastAddress, String sourceToBlock, Handler<AsyncResult<DatagramSocket>> handler)
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 completespublic rx.Observable<DatagramSocket> blockMulticastGroupObservable(String multicastAddress, String sourceToBlock)
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.public DatagramSocket blockMulticastGroup(String multicastAddress, String networkInterface, String sourceToBlock, Handler<AsyncResult<DatagramSocket>> handler)
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 completespublic rx.Observable<DatagramSocket> blockMulticastGroupObservable(String multicastAddress, String networkInterface, String sourceToBlock)
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.public DatagramSocket 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 listeningpublic rx.Observable<DatagramSocket> listenObservable(int port, String host)
port - the port to listen onhost - the host to listen onpublic DatagramSocket pause()
ReadStreamReadSupport. While it's paused, no data will be sent to the dataHandlerpause in interface ReadStream<DatagramPacket>public DatagramSocket resume()
ReadStreamReadSupport has been paused, reading will recommence on it.resume in interface ReadStream<DatagramPacket>public DatagramSocket endHandler(Handler<Void> endHandler)
ReadStreamendHandler in interface ReadStream<DatagramPacket>public DatagramSocket handler(Handler<DatagramPacket> handler)
ReadStreamhandler in interface ReadStream<DatagramPacket>public DatagramSocket exceptionHandler(Handler<Throwable> handler)
ReadStreamexceptionHandler in interface ReadStream<DatagramPacket>exceptionHandler in interface StreamBasehandler - the exception handlerpublic static DatagramSocket newInstance(DatagramSocket arg)
Copyright © 2015. All rights reserved.