Class DatagramSocket
- java.lang.Object
-
- io.vertx.rxjava.core.datagram.DatagramSocket
-
- All Implemented Interfaces:
Measured,ReadStream<DatagramPacket>,StreamBase
public class DatagramSocket extends Object implements ReadStream<DatagramPacket>, Measured
A datagram socket can be used to sendDatagramPacket's to remote datagram servers and receiveDatagramPackets .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 theoriginalnon RX-ified interface using Vert.x codegen.
-
-
Field Summary
Fields Modifier and Type Field Description static 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 Deprecated Methods Modifier and Type Method Description DatagramSocketblockMulticastGroup(String multicastAddress, String sourceToBlock)Block the given address for the given multicast address and notifies the once the operation completes.DatagramSocketblockMulticastGroup(String multicastAddress, String sourceToBlock, Handler<AsyncResult<Void>> handler)Block the given address for the given multicast address and notifies the once the operation completes.DatagramSocketblockMulticastGroup(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.DatagramSocketblockMulticastGroup(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.voidclose()Closes theDatagramSocketimplementation asynchronous and notifies the handler once done.voidclose(Handler<AsyncResult<Void>> handler)Closes theDatagramSocketimplementation asynchronous and notifies the handler once done.DatagramSocketendHandler(Handler<Void> endHandler)Deprecated.booleanequals(Object o)DatagramSocketexceptionHandler(Handler<Throwable> handler)Set an exception handler on the read stream.DatagramSocketfetch(long amount)Deprecated.DatagramSocketgetDelegate()DatagramSockethandler(Handler<DatagramPacket> handler)Set a data handler.inthashCode()booleanisMetricsEnabled()Whether the metrics are enabled for this measured objectDatagramSocketlisten(int port, String host)Start listening on the given port and host.DatagramSocketlisten(int port, String host, Handler<AsyncResult<DatagramSocket>> handler)Start listening on the given port and host.DatagramSocketlistenMulticastGroup(String multicastAddress)Joins a multicast group and listens for packets send to it.DatagramSocketlistenMulticastGroup(String multicastAddress, Handler<AsyncResult<Void>> handler)Joins a multicast group and listens for packets send to it.DatagramSocketlistenMulticastGroup(String multicastAddress, String networkInterface, String source)Joins a multicast group and listens for packets send to it on the given network interface.DatagramSocketlistenMulticastGroup(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.SocketAddresslocalAddress()Return theSocketAddressto which thisDatagramSocketis bound.static DatagramSocketnewInstance(DatagramSocket arg)DatagramSocketpause()Deprecated.Pipe<DatagramPacket>pipe()Pause this stream and return a to transfer the elements of this stream to a destination .voidpipeTo(WriteStream<DatagramPacket> dst)Pipe thisReadStreamto theWriteStream.voidpipeTo(WriteStream<DatagramPacket> dst, Handler<AsyncResult<Void>> handler)Pipe thisReadStreamto theWriteStream.DatagramSocketresume()Deprecated.rx.Single<Void>rxBlockMulticastGroup(String multicastAddress, String sourceToBlock)Block the given address for the given multicast address and notifies the once the operation completes.rx.Single<Void>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.rx.Single<Void>rxClose()Closes theDatagramSocketimplementation asynchronous and notifies the handler once done.rx.Single<DatagramSocket>rxListen(int port, String host)Start listening on the given port and host.rx.Single<Void>rxListenMulticastGroup(String multicastAddress)Joins a multicast group and listens for packets send to it.rx.Single<Void>rxListenMulticastGroup(String multicastAddress, String networkInterface, String source)Joins a multicast group and listens for packets send to it on the given network interface.rx.Single<Void>rxPipeTo(WriteStream<DatagramPacket> dst)Pipe thisReadStreamto theWriteStream.rx.Single<Void>rxSend(Buffer packet, int port, String host)Write the givenBufferto theSocketAddress.rx.Single<Void>rxSend(String str, int port, String host)Write the givenStringto theSocketAddressusing UTF8 encoding.rx.Single<Void>rxSend(String str, String enc, int port, String host)Write the givenStringto theSocketAddressusing the given encoding.rx.Single<Void>rxUnlistenMulticastGroup(String multicastAddress)Leaves a multicast group and stops listening for packets send to it.rx.Single<Void>rxUnlistenMulticastGroup(String multicastAddress, String networkInterface, String source)Leaves a multicast group and stops listening for packets send to it on the given network interface.DatagramSocketsend(Buffer packet, int port, String host)Write the givenBufferto theSocketAddress.DatagramSocketsend(Buffer packet, int port, String host, Handler<AsyncResult<Void>> handler)Write the givenBufferto theSocketAddress.DatagramSocketsend(String str, int port, String host)Write the givenStringto theSocketAddressusing UTF8 encoding.DatagramSocketsend(String str, int port, String host, Handler<AsyncResult<Void>> handler)Write the givenStringto theSocketAddressusing UTF8 encoding.DatagramSocketsend(String str, String enc, int port, String host)Write the givenStringto theSocketAddressusing the given encoding.DatagramSocketsend(String str, String enc, int port, String host, Handler<AsyncResult<Void>> handler)Write the givenStringto theSocketAddressusing the given encoding.WriteStream<Buffer>sender(int port, String host)Returns aWriteStreamable to send to theSocketAddress.rx.Observable<DatagramPacket>toObservable()StringtoString()DatagramSocketunlistenMulticastGroup(String multicastAddress)Leaves a multicast group and stops listening for packets send to it.DatagramSocketunlistenMulticastGroup(String multicastAddress, Handler<AsyncResult<Void>> handler)Leaves a multicast group and stops listening for packets send to it.DatagramSocketunlistenMulticastGroup(String multicastAddress, String networkInterface, String source)Leaves a multicast group and stops listening for packets send to it on the given network interface.DatagramSocketunlistenMulticastGroup(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.
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<DatagramSocket> __TYPE_ARG
-
-
Constructor Detail
-
DatagramSocket
public DatagramSocket(DatagramSocket delegate)
-
DatagramSocket
public DatagramSocket(Object delegate)
-
-
Method Detail
-
getDelegate
public DatagramSocket getDelegate()
- Specified by:
getDelegatein interfaceMeasured- Specified by:
getDelegatein interfaceReadStream<DatagramPacket>- Specified by:
getDelegatein interfaceStreamBase
-
toObservable
public rx.Observable<DatagramPacket> toObservable()
- Specified by:
toObservablein interfaceReadStream<DatagramPacket>
-
isMetricsEnabled
public boolean isMetricsEnabled()
Whether the metrics are enabled for this measured object- Specified by:
isMetricsEnabledin interfaceMeasured- Returns:
trueif metrics are enabled
-
pipe
public Pipe<DatagramPacket> pipe()
Pause this stream and return a to transfer the elements of this stream to a destination . The stream will be resumed when the pipe will be wired to aWriteStream.- Specified by:
pipein interfaceReadStream<DatagramPacket>- Returns:
- a pipe
-
pipeTo
public void pipeTo(WriteStream<DatagramPacket> dst, Handler<AsyncResult<Void>> handler)
Pipe thisReadStreamto theWriteStream.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
handlerwill be called with the result.- Specified by:
pipeToin interfaceReadStream<DatagramPacket>- Parameters:
dst- the destination write streamhandler-
-
pipeTo
public void pipeTo(WriteStream<DatagramPacket> dst)
Pipe thisReadStreamto theWriteStream.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
handlerwill be called with the result.- Specified by:
pipeToin interfaceReadStream<DatagramPacket>- Parameters:
dst- the destination write stream
-
rxPipeTo
public rx.Single<Void> rxPipeTo(WriteStream<DatagramPacket> dst)
Pipe thisReadStreamto theWriteStream.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
handlerwill be called with the result.- Specified by:
rxPipeToin interfaceReadStream<DatagramPacket>- Parameters:
dst- the destination write stream- Returns:
-
send
public DatagramSocket send(Buffer packet, int port, String host, Handler<AsyncResult<Void>> handler)
-
send
public DatagramSocket send(Buffer packet, int port, String host)
- Parameters:
packet- theBufferto writeport- the host port of the remote peerhost- the host address of the remote peer- Returns:
- a reference to this, so the API can be used fluently
-
rxSend
public rx.Single<Void> rxSend(Buffer packet, int port, String host)
- Parameters:
packet- theBufferto writeport- the host port of the remote peerhost- the host address of the remote peer- Returns:
- a reference to this, so the API can be used fluently
-
sender
public WriteStream<Buffer> sender(int port, String host)
Returns aWriteStreamable 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 DatagramSocket send(String str, int port, String host, Handler<AsyncResult<Void>> handler)
Write the givenStringto theSocketAddressusing UTF8 encoding. The will be notified once the write completes.
-
send
public DatagramSocket send(String str, int port, String host)
Write the givenStringto theSocketAddressusing UTF8 encoding. The will be notified once the write completes.- Parameters:
str- theStringto writeport- the host port of the remote peerhost- the host address of the remote peer- Returns:
- a reference to this, so the API can be used fluently
-
rxSend
public rx.Single<Void> rxSend(String str, int port, String host)
Write the givenStringto theSocketAddressusing UTF8 encoding. The will be notified once the write completes.- Parameters:
str- theStringto writeport- the host port of the remote peerhost- the host address of the remote peer- Returns:
- a reference to this, so the API can be used fluently
-
send
public DatagramSocket send(String str, String enc, int port, String host, Handler<AsyncResult<Void>> handler)
Write the givenStringto theSocketAddressusing the given encoding. The will be notified once the write completes.
-
send
public DatagramSocket send(String str, String enc, int port, String host)
Write the givenStringto theSocketAddressusing the given encoding. The will be notified once the write completes.- Parameters:
str- theStringto writeenc- the charset used for encodingport- the host port of the remote peerhost- the host address of the remote peer- Returns:
- a reference to this, so the API can be used fluently
-
rxSend
public rx.Single<Void> rxSend(String str, String enc, int port, String host)
Write the givenStringto theSocketAddressusing the given encoding. The will be notified once the write completes.- Parameters:
str- theStringto writeenc- the charset used for encodingport- the host port of the remote peerhost- the host address of the remote peer- Returns:
- a reference to this, so the API can be used fluently
-
close
public void close(Handler<AsyncResult<Void>> handler)
Closes theDatagramSocketimplementation asynchronous and notifies the handler once done.- Parameters:
handler- the handler to notify once complete
-
close
public void close()
Closes theDatagramSocketimplementation asynchronous and notifies the handler once done.
-
rxClose
public rx.Single<Void> rxClose()
Closes theDatagramSocketimplementation asynchronous and notifies the handler once done.- Returns:
-
localAddress
public SocketAddress localAddress()
Return theSocketAddressto which thisDatagramSocketis bound.- Returns:
- the socket address
-
listenMulticastGroup
public DatagramSocket listenMulticastGroup(String multicastAddress, Handler<AsyncResult<Void>> handler)
Joins a multicast group and listens for packets send to it. The is notified once the operation completes.- Parameters:
multicastAddress- the address of the multicast group to joinhandler- then handler to notify once the operation completes- Returns:
- a reference to this, so the API can be used fluently
-
listenMulticastGroup
public DatagramSocket listenMulticastGroup(String multicastAddress)
Joins a multicast group and listens for packets send to it. The is notified once the operation completes.- Parameters:
multicastAddress- the address of the multicast group to join- Returns:
- a reference to this, so the API can be used fluently
-
rxListenMulticastGroup
public rx.Single<Void> rxListenMulticastGroup(String multicastAddress)
Joins a multicast group and listens for packets send to it. The is notified once the operation completes.- Parameters:
multicastAddress- the address of the multicast group to join- Returns:
- a reference to this, so the API can be used fluently
-
listenMulticastGroup
public 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. The is notified once the operation completes.- 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 packetshandler- then handler to notify once the operation completes- Returns:
- a reference to this, so the API can be used fluently
-
listenMulticastGroup
public DatagramSocket listenMulticastGroup(String multicastAddress, String networkInterface, String source)
Joins a multicast group and listens for packets send to it on the given network interface. The is notified once the operation completes.- 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 reference to this, so the API can be used fluently
-
rxListenMulticastGroup
public rx.Single<Void> rxListenMulticastGroup(String multicastAddress, String networkInterface, String source)
Joins a multicast group and listens for packets send to it on the given network interface. The is notified once the operation completes.- 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 reference to this, so the API can be used fluently
-
unlistenMulticastGroup
public DatagramSocket unlistenMulticastGroup(String multicastAddress, Handler<AsyncResult<Void>> handler)
Leaves a multicast group and stops listening for packets send to it. The is notified once the operation completes.- Parameters:
multicastAddress- the address of the multicast group to leavehandler- then handler to notify once the operation completes- Returns:
- a reference to this, so the API can be used fluently
-
unlistenMulticastGroup
public DatagramSocket unlistenMulticastGroup(String multicastAddress)
Leaves a multicast group and stops listening for packets send to it. The is notified once the operation completes.- Parameters:
multicastAddress- the address of the multicast group to leave- Returns:
- a reference to this, so the API can be used fluently
-
rxUnlistenMulticastGroup
public rx.Single<Void> rxUnlistenMulticastGroup(String multicastAddress)
Leaves a multicast group and stops listening for packets send to it. The is notified once the operation completes.- Parameters:
multicastAddress- the address of the multicast group to leave- Returns:
- a reference to this, so the API can be used fluently
-
unlistenMulticastGroup
public 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. The is notified once the operation completes.- 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 packetshandler- the handler to notify once the operation completes- Returns:
- a reference to this, so the API can be used fluently
-
unlistenMulticastGroup
public 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. The is notified once the operation completes.- 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 reference to this, so the API can be used fluently
-
rxUnlistenMulticastGroup
public rx.Single<Void> rxUnlistenMulticastGroup(String multicastAddress, String networkInterface, String source)
Leaves a multicast group and stops listening for packets send to it on the given network interface. The is notified once the operation completes.- 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 reference to this, so the API can be used fluently
-
blockMulticastGroup
public 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.- 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.handler- the handler to notify once the operation completes- Returns:
- a reference to this, so the API can be used fluently
-
blockMulticastGroup
public DatagramSocket 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 reference to this, so the API can be used fluently
-
rxBlockMulticastGroup
public rx.Single<Void> 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 reference to this, so the API can be used fluently
-
blockMulticastGroup
public 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.- 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.handler- the handler to notify once the operation completes- Returns:
- a reference to this, so the API can be used fluently
-
blockMulticastGroup
public 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.- 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 reference to this, so the API can be used fluently
-
rxBlockMulticastGroup
public rx.Single<Void> 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 reference to this, so the API can be used fluently
-
listen
public DatagramSocket listen(int port, String host, Handler<AsyncResult<DatagramSocket>> handler)
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 onhandler- the handler will be called when listening- Returns:
- a reference to this, so the API can be used fluently
-
listen
public 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 reference to this, so the API can be used fluently
-
rxListen
public rx.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 reference to this, so the API can be used fluently
-
pause
@Deprecated public DatagramSocket pause()
Deprecated.Description copied from interface:ReadStreamPause theReadStream, it sets the buffer infetchmode and clears the actual demand.While it's paused, no data will be sent to the data
handler.- Specified by:
pausein interfaceReadStream<DatagramPacket>- Returns:
-
resume
@Deprecated public DatagramSocket resume()
Deprecated.Description copied from interface:ReadStreamResume reading, and sets the buffer inflowingmode. If theReadStreamhas been paused, reading will recommence on it.- Specified by:
resumein interfaceReadStream<DatagramPacket>- Returns:
-
fetch
@Deprecated public DatagramSocket fetch(long amount)
Deprecated.Description copied from interface:ReadStreamFetch the specifiedamountof elements. If theReadStreamhas been paused, reading will recommence with the specifiedamountof items, otherwise the specifiedamountwill be added to the current stream demand.- Specified by:
fetchin interfaceReadStream<DatagramPacket>- Parameters:
amount-- Returns:
-
endHandler
@Deprecated public DatagramSocket endHandler(Handler<Void> endHandler)
Deprecated.Description copied from interface:ReadStreamSet an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called.- Specified by:
endHandlerin interfaceReadStream<DatagramPacket>- Parameters:
endHandler-- Returns:
-
handler
public DatagramSocket handler(Handler<DatagramPacket> handler)
Description copied from interface:ReadStreamSet a data handler. As data is read, the handler will be called with the data.- Specified by:
handlerin interfaceReadStream<DatagramPacket>- Returns:
- a reference to this, so the API can be used fluently
-
exceptionHandler
public DatagramSocket exceptionHandler(Handler<Throwable> handler)
Description copied from interface:ReadStreamSet an exception handler on the read stream.- Specified by:
exceptionHandlerin interfaceReadStream<DatagramPacket>- Specified by:
exceptionHandlerin interfaceStreamBase- Parameters:
handler- the exception handler- Returns:
- a reference to this, so the API can be used fluently
-
newInstance
public static DatagramSocket newInstance(DatagramSocket arg)
-
-