public class DatagramSocket extends Object implements ReadStream<DatagramPacket>, Measured
DatagramPacket
's to remote datagram servers
and receive DatagramPacket
s .
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.Modifier and Type | Field and Description |
---|---|
static io.vertx.lang.rx.TypeArg<DatagramSocket> |
__TYPE_ARG |
Constructor and Description |
---|
DatagramSocket(DatagramSocket delegate) |
DatagramSocket(Object delegate) |
Modifier and Type | Method and Description |
---|---|
DatagramSocket |
blockMulticastGroup(String multicastAddress,
String sourceToBlock)
Block the given address for the given multicast address and notifies the once
the operation completes.
|
DatagramSocket |
blockMulticastGroup(String multicastAddress,
String sourceToBlock,
Handler<AsyncResult<Void>> 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)
Block the given address for the given multicast address on the given network interface and notifies
the once the operation completes.
|
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 once the operation completes.
|
void |
close()
Closes the
DatagramSocket implementation asynchronous
and notifies the handler once done. |
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.
|
boolean |
equals(Object o) |
DatagramSocket |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler on the read stream.
|
DatagramSocket |
fetch(long amount)
Fetch the specified
amount of elements. |
DatagramSocket |
getDelegate() |
DatagramSocket |
handler(Handler<DatagramPacket> handler)
Set a data handler.
|
int |
hashCode() |
boolean |
isMetricsEnabled()
Whether the metrics are enabled for this measured object
|
DatagramSocket |
listen(int port,
String host)
Start listening on the given port and host.
|
DatagramSocket |
listen(int port,
String host,
Handler<AsyncResult<DatagramSocket>> handler)
Start listening on the given port and host.
|
DatagramSocket |
listenMulticastGroup(String multicastAddress)
Joins a multicast group and listens for packets send to it.
|
DatagramSocket |
listenMulticastGroup(String multicastAddress,
Handler<AsyncResult<Void>> handler)
Joins a multicast group and listens for packets send to it.
|
DatagramSocket |
listenMulticastGroup(String multicastAddress,
String networkInterface,
String source)
Joins a multicast group and listens for packets send to it on the given network interface.
|
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. |
static DatagramSocket |
newInstance(DatagramSocket arg) |
DatagramSocket |
pause()
Pause the
ReadStream , it sets the buffer in fetch mode and clears the actual demand. |
Pipe<DatagramPacket> |
pipe()
Pause this stream and return a to transfer the elements of this stream to a destination .
|
void |
pipeTo(WriteStream<DatagramPacket> dst)
Pipe this
ReadStream to the WriteStream . |
void |
pipeTo(WriteStream<DatagramPacket> dst,
Handler<AsyncResult<Void>> handler)
Pipe this
ReadStream to the WriteStream . |
DatagramSocket |
resume()
Resume reading, and sets the buffer in
flowing mode. |
Completable |
rxBlockMulticastGroup(String multicastAddress,
String sourceToBlock)
Block the given address for the given multicast address and notifies the once
the operation completes.
|
Completable |
rxBlockMulticastGroup(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.
|
Completable |
rxClose()
Closes the
DatagramSocket implementation asynchronous
and notifies the handler once done. |
Single<DatagramSocket> |
rxListen(int port,
String host)
Start listening on the given port and host.
|
Completable |
rxListenMulticastGroup(String multicastAddress)
Joins a multicast group and listens for packets send to it.
|
Completable |
rxListenMulticastGroup(String multicastAddress,
String networkInterface,
String source)
Joins a multicast group and listens for packets send to it on the given network interface.
|
Completable |
rxPipeTo(WriteStream<DatagramPacket> dst)
Pipe this
ReadStream to the WriteStream . |
Completable |
rxSend(Buffer packet,
int port,
String host)
Write the given
Buffer to the SocketAddress . |
Completable |
rxSend(String str,
int port,
String host)
Write the given
String to the SocketAddress using UTF8 encoding. |
Completable |
rxSend(String str,
String enc,
int port,
String host)
Write the given
String to the SocketAddress using the given encoding. |
Completable |
rxUnlistenMulticastGroup(String multicastAddress)
Leaves a multicast group and stops listening for packets send to it.
|
Completable |
rxUnlistenMulticastGroup(String multicastAddress,
String networkInterface,
String source)
Leaves a multicast group and stops listening for packets send to it on the given network interface.
|
DatagramSocket |
send(Buffer packet,
int port,
String host)
Write the given
Buffer to the SocketAddress . |
DatagramSocket |
send(Buffer packet,
int port,
String host,
Handler<AsyncResult<Void>> handler)
Write the given
Buffer to the SocketAddress . |
DatagramSocket |
send(String str,
int port,
String host)
Write the given
String to the SocketAddress using UTF8 encoding. |
DatagramSocket |
send(String str,
int port,
String host,
Handler<AsyncResult<Void>> handler)
Write the given
String to the SocketAddress using UTF8 encoding. |
DatagramSocket |
send(String str,
String enc,
int port,
String host)
Write the given
String to the SocketAddress using the given encoding. |
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)
Returns a
WriteStream able to send to the
SocketAddress . |
Flowable<DatagramPacket> |
toFlowable() |
Observable<DatagramPacket> |
toObservable() |
String |
toString() |
DatagramSocket |
unlistenMulticastGroup(String multicastAddress)
Leaves a multicast group and stops listening for packets send to it.
|
DatagramSocket |
unlistenMulticastGroup(String multicastAddress,
Handler<AsyncResult<Void>> handler)
Leaves a multicast group and stops listening for packets send to it.
|
DatagramSocket |
unlistenMulticastGroup(String multicastAddress,
String networkInterface,
String source)
Leaves a multicast group and stops listening for packets send to it on the given network interface.
|
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.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
newInstance, newInstance
newInstance
newInstance
public static final io.vertx.lang.rx.TypeArg<DatagramSocket> __TYPE_ARG
public DatagramSocket(DatagramSocket delegate)
public DatagramSocket(Object delegate)
public DatagramSocket getDelegate()
getDelegate
in interface Measured
getDelegate
in interface ReadStream<DatagramPacket>
getDelegate
in interface StreamBase
public Observable<DatagramPacket> toObservable()
toObservable
in interface ReadStream<DatagramPacket>
public Flowable<DatagramPacket> toFlowable()
toFlowable
in interface ReadStream<DatagramPacket>
public boolean isMetricsEnabled()
isMetricsEnabled
in interface Measured
true
if metrics are enabledpublic Pipe<DatagramPacket> pipe()
WriteStream
.pipe
in interface ReadStream<DatagramPacket>
public void pipeTo(WriteStream<DatagramPacket> dst, Handler<AsyncResult<Void>> handler)
ReadStream
to the WriteStream
.
Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Once this stream has ended or failed, the write stream will be ended and the handler
will be
called with the result.
pipeTo
in interface ReadStream<DatagramPacket>
dst
- the destination write streamhandler
- public void pipeTo(WriteStream<DatagramPacket> dst)
ReadStream
to the WriteStream
.
Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Once this stream has ended or failed, the write stream will be ended and the handler
will be
called with the result.
pipeTo
in interface ReadStream<DatagramPacket>
dst
- the destination write streampublic Completable rxPipeTo(WriteStream<DatagramPacket> dst)
ReadStream
to the WriteStream
.
Elements emitted by this stream will be written to the write stream until this stream ends or fails.
Once this stream has ended or failed, the write stream will be ended and the handler
will be
called with the result.
rxPipeTo
in interface ReadStream<DatagramPacket>
dst
- the destination write streampublic DatagramSocket send(Buffer packet, int port, String host, Handler<AsyncResult<Void>> handler)
public DatagramSocket send(Buffer packet, int port, String host)
packet
- the Buffer
to writeport
- the host port of the remote peerhost
- the host address of the remote peerpublic Completable rxSend(Buffer packet, int port, String host)
packet
- the Buffer
to writeport
- the host port of the remote peerhost
- the host address of the remote peerpublic WriteStream<Buffer> sender(int port, String host)
WriteStream
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<Void>> handler)
String
to the SocketAddress
using UTF8 encoding.
The will be notified once the write completes.public DatagramSocket send(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 Completable rxSend(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<Void>> handler)
String
to the SocketAddress
using the given encoding.
The will be notified once the write completes.public DatagramSocket send(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 Completable rxSend(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 void close()
DatagramSocket
implementation asynchronous
and notifies the handler once done.public Completable rxClose()
DatagramSocket
implementation asynchronous
and notifies the handler once done.public SocketAddress localAddress()
SocketAddress
to which
this DatagramSocket
is bound.public DatagramSocket listenMulticastGroup(String multicastAddress, Handler<AsyncResult<Void>> handler)
multicastAddress
- the address of the multicast group to joinhandler
- then handler to notify once the operation completespublic DatagramSocket listenMulticastGroup(String multicastAddress)
multicastAddress
- the address of the multicast group to joinpublic Completable rxListenMulticastGroup(String multicastAddress)
multicastAddress
- the address of the multicast group to joinpublic DatagramSocket listenMulticastGroup(String multicastAddress, String networkInterface, String source, Handler<AsyncResult<Void>> 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 DatagramSocket listenMulticastGroup(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 Completable rxListenMulticastGroup(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<Void>> handler)
multicastAddress
- the address of the multicast group to leavehandler
- then handler to notify once the operation completespublic DatagramSocket unlistenMulticastGroup(String multicastAddress)
multicastAddress
- the address of the multicast group to leavepublic Completable rxUnlistenMulticastGroup(String multicastAddress)
multicastAddress
- the address of the multicast group to leavepublic DatagramSocket unlistenMulticastGroup(String multicastAddress, String networkInterface, String source, Handler<AsyncResult<Void>> 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 DatagramSocket unlistenMulticastGroup(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 Completable rxUnlistenMulticastGroup(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<Void>> 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 DatagramSocket blockMulticastGroup(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 Completable rxBlockMulticastGroup(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<Void>> 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 DatagramSocket blockMulticastGroup(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 Completable rxBlockMulticastGroup(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 DatagramSocket listen(int port, String host)
port
- the port to listen onhost
- the host to listen onpublic Single<DatagramSocket> rxListen(int port, String host)
port
- the port to listen onhost
- the host to listen onpublic DatagramSocket pause()
ReadStream
ReadStream
, 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>
public DatagramSocket resume()
ReadStream
flowing
mode.
If the ReadStream
has been paused, reading will recommence on it.resume
in interface ReadStream<DatagramPacket>
public DatagramSocket fetch(long amount)
ReadStream
amount
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>
public DatagramSocket endHandler(Handler<Void> endHandler)
ReadStream
endHandler
in interface ReadStream<DatagramPacket>
public DatagramSocket handler(Handler<DatagramPacket> handler)
ReadStream
handler
in interface ReadStream<DatagramPacket>
public DatagramSocket exceptionHandler(Handler<Throwable> handler)
ReadStream
exceptionHandler
in interface ReadStream<DatagramPacket>
exceptionHandler
in interface StreamBase
handler
- the exception handlerpublic static DatagramSocket newInstance(DatagramSocket arg)
Copyright © 2021 Eclipse. All rights reserved.