Package io.vertx.rxjava3.core.datagram
Class DatagramSocket
- java.lang.Object
-
- io.vertx.rxjava3.core.datagram.DatagramSocket
-
- All Implemented Interfaces:
io.vertx.lang.rx.RxDelegate
,Measured
public class DatagramSocket extends Object implements io.vertx.lang.rx.RxDelegate, Measured
A datagram socket can be used to sendDatagramPacket
's to remote datagram servers and receiveDatagramPacket
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 the
original
non RX-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static io.vertx.lang.rx.TypeArg<DatagramSocket>
__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description DatagramSocket(DatagramSocket delegate)
DatagramSocket(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Completable
blockMulticastGroup(String multicastAddress, String sourceToBlock)
Block the given address for the given multicast address and notifies the once the operation completes.Completable
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.Completable
close()
Closes theDatagramSocket
implementation asynchronous and notifies the handler once done.boolean
equals(Object o)
DatagramSocket
exceptionHandler(Handler<Throwable> handler)
DatagramSocket
getDelegate()
DatagramSocket
handler(Handler<DatagramPacket> handler)
int
hashCode()
boolean
isMetricsEnabled()
Whether the metrics are enabled for this measured objectSingle<DatagramSocket>
listen(int port, String host)
Start listening on the given port and host.Completable
listenMulticastGroup(String multicastAddress)
Joins a multicast group and listens for packets send to it.Completable
listenMulticastGroup(String multicastAddress, String networkInterface, String source)
Joins a multicast group and listens for packets send to it on the given network interface.SocketAddress
localAddress()
Return theSocketAddress
to which thisDatagramSocket
is bound.static DatagramSocket
newInstance(DatagramSocket arg)
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 theDatagramSocket
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
rxSend(Buffer packet, int port, String host)
Write the givenBuffer
to theSocketAddress
.Completable
rxSend(String str, int port, String host)
Write the givenString
to theSocketAddress
using UTF8 encoding.Completable
rxSend(String str, String enc, int port, String host)
Write the givenString
to theSocketAddress
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.Completable
send(Buffer packet, int port, String host)
Write the givenBuffer
to theSocketAddress
.Completable
send(String str, int port, String host)
Write the givenString
to theSocketAddress
using UTF8 encoding.Completable
send(String str, String enc, int port, String host)
Write the givenString
to theSocketAddress
using the given encoding.WriteStream<Buffer>
sender(int port, String host)
Returns aWriteStream
able to send to theSocketAddress
.String
toString()
Completable
unlistenMulticastGroup(String multicastAddress)
Leaves a multicast group and stops listening for packets send to it.Completable
unlistenMulticastGroup(String multicastAddress, String networkInterface, String source)
Leaves a multicast group and stops listening for packets send to it on the given network interface.
-
-
-
Field Detail
-
__TYPE_ARG
public static final io.vertx.lang.rx.TypeArg<DatagramSocket> __TYPE_ARG
-
-
Constructor Detail
-
DatagramSocket
public DatagramSocket(DatagramSocket delegate)
-
DatagramSocket
public DatagramSocket(Object delegate)
-
-
Method Detail
-
getDelegate
public DatagramSocket getDelegate()
- Specified by:
getDelegate
in interfaceMeasured
- Specified by:
getDelegate
in interfaceio.vertx.lang.rx.RxDelegate
-
isMetricsEnabled
public boolean isMetricsEnabled()
Whether the metrics are enabled for this measured object- Specified by:
isMetricsEnabled
in interfaceMeasured
- Returns:
true
if metrics are enabled
-
send
public Completable send(Buffer packet, int port, String host)
Write the givenBuffer
to theSocketAddress
.- Parameters:
packet
- theBuffer
to writeport
- the host port of the remote peerhost
- the host address of the remote peer- Returns:
- a future notified once the write completes.
-
rxSend
public Completable rxSend(Buffer packet, int port, String host)
Write the givenBuffer
to theSocketAddress
.- Parameters:
packet
- theBuffer
to writeport
- the host port of the remote peerhost
- the host address of the remote peer- Returns:
- a future notified once the write completes.
-
sender
public WriteStream<Buffer> sender(int port, String host)
Returns aWriteStream
able to send to theSocketAddress
.- Parameters:
port
- the port of the remote peerhost
- the host address of the remote peer- Returns:
- the write stream for sending packets
-
send
public Completable send(String str, int port, String host)
Write the givenString
to theSocketAddress
using UTF8 encoding.- Parameters:
str
- theString
to writeport
- the host port of the remote peerhost
- the host address of the remote peer- Returns:
- a future notified once the write completes.
-
rxSend
public Completable rxSend(String str, int port, String host)
Write the givenString
to theSocketAddress
using UTF8 encoding.- Parameters:
str
- theString
to writeport
- the host port of the remote peerhost
- the host address of the remote peer- Returns:
- a future notified once the write completes.
-
send
public Completable send(String str, String enc, int port, String host)
Write the givenString
to theSocketAddress
using the given encoding.- Parameters:
str
- theString
to writeenc
- the charset used for encodingport
- the host port of the remote peerhost
- the host address of the remote peer- Returns:
- a future notified once the write completes.
-
rxSend
public Completable rxSend(String str, String enc, int port, String host)
Write the givenString
to theSocketAddress
using the given encoding.- Parameters:
str
- theString
to writeenc
- the charset used for encodingport
- the host port of the remote peerhost
- the host address of the remote peer- Returns:
- a future notified once the write completes.
-
close
public Completable close()
Closes theDatagramSocket
implementation asynchronous and notifies the handler once done.- Returns:
- a future notified once the socket is closed
-
rxClose
public Completable rxClose()
Closes theDatagramSocket
implementation asynchronous and notifies the handler once done.- Returns:
- a future notified once the socket is closed
-
localAddress
public SocketAddress localAddress()
Return theSocketAddress
to which thisDatagramSocket
is bound.- Returns:
- the socket address
-
listenMulticastGroup
public Completable listenMulticastGroup(String multicastAddress)
Joins a multicast group and listens for packets send to it.- Parameters:
multicastAddress
- the address of the multicast group to join- Returns:
- a future notified once the operation completes
-
rxListenMulticastGroup
public Completable rxListenMulticastGroup(String multicastAddress)
Joins a multicast group and listens for packets send to it.- Parameters:
multicastAddress
- the address of the multicast group to join- Returns:
- a future notified once the operation completes
-
listenMulticastGroup
public Completable listenMulticastGroup(String multicastAddress, String networkInterface, String source)
Joins a multicast group and listens for packets send to it on the given network interface.- Parameters:
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 packets- Returns:
- a future notified once the operation completes
-
rxListenMulticastGroup
public Completable rxListenMulticastGroup(String multicastAddress, String networkInterface, String source)
Joins a multicast group and listens for packets send to it on the given network interface.- Parameters:
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 packets- Returns:
- a future notified once the operation completes
-
unlistenMulticastGroup
public Completable unlistenMulticastGroup(String multicastAddress)
Leaves a multicast group and stops listening for packets send to it.- Parameters:
multicastAddress
- the address of the multicast group to leave- Returns:
- a future notified once the operation completes
-
rxUnlistenMulticastGroup
public Completable rxUnlistenMulticastGroup(String multicastAddress)
Leaves a multicast group and stops listening for packets send to it.- Parameters:
multicastAddress
- the address of the multicast group to leave- Returns:
- a future notified once the operation completes
-
unlistenMulticastGroup
public Completable unlistenMulticastGroup(String multicastAddress, String networkInterface, String source)
Leaves a multicast group and stops listening for packets send to it on the given network interface.- Parameters:
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 packets- Returns:
- a future notified once the operation completes
-
rxUnlistenMulticastGroup
public 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.- Parameters:
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 packets- Returns:
- a future notified once the operation completes
-
blockMulticastGroup
public Completable blockMulticastGroup(String multicastAddress, String sourceToBlock)
Block the given address for the given multicast address and notifies the once the operation completes.- Parameters:
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.- Returns:
- a future notified once the operation completes
-
rxBlockMulticastGroup
public Completable rxBlockMulticastGroup(String multicastAddress, String sourceToBlock)
Block the given address for the given multicast address and notifies the once the operation completes.- Parameters:
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.- Returns:
- a future notified once the operation completes
-
blockMulticastGroup
public Completable 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.- Parameters:
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.- Returns:
- a future notified once the operation completes
-
rxBlockMulticastGroup
public 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.- Parameters:
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.- Returns:
- a future notified once the operation completes
-
listen
public Single<DatagramSocket> listen(int port, String host)
Start listening on the given port and host. The handler will be called when the socket is listening.- Parameters:
port
- the port to listen onhost
- the host to listen on- Returns:
- a future notified once the operation completes
-
rxListen
public Single<DatagramSocket> rxListen(int port, String host)
Start listening on the given port and host. The handler will be called when the socket is listening.- Parameters:
port
- the port to listen onhost
- the host to listen on- Returns:
- a future notified once the operation completes
-
handler
public DatagramSocket handler(Handler<DatagramPacket> handler)
-
exceptionHandler
public DatagramSocket exceptionHandler(Handler<Throwable> handler)
-
newInstance
public static DatagramSocket newInstance(DatagramSocket arg)
-
-