public abstract class UDPClient extends TimedEntry
| Constructor and Description |
|---|
UDPClient(int localPort,
AddressFilter filter,
UDPDatagramHandler handler,
java.lang.String comManId) |
UDPClient(IPAddress localAddress,
int localPort,
NetworkInterface iface,
AddressFilter filter,
UDPDatagramHandler handler,
java.lang.String comManId,
boolean forceMulticastSocket) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes an existing UDP listener.
|
void |
ensureOpen() |
NetworkInterface |
getIface() |
IPAddress |
getIPAddress() |
int |
getPort() |
boolean |
hasListener() |
boolean |
isClosed()
Returns
true if the client is closed and cannot be used for a request, or
false if the client can still be used. |
void |
send(Message message,
AttributedURI optionalMessageId,
IPConnectionInfo connectionInfo,
Datagram datagram)
Creates a UDP datagram socket and uses this socket to send the given data as UDP datagram
packet.
|
protected void |
timedOut()
Runs what should be done at time out.
|
isDisabled, toStringpublic UDPClient(IPAddress localAddress, int localPort, NetworkInterface iface, AddressFilter filter, UDPDatagramHandler handler, java.lang.String comManId, boolean forceMulticastSocket) throws java.io.IOException
java.io.IOExceptionpublic UDPClient(int localPort,
AddressFilter filter,
UDPDatagramHandler handler,
java.lang.String comManId)
throws java.io.IOException
java.io.IOExceptionpublic void send(Message message, AttributedURI optionalMessageId, IPConnectionInfo connectionInfo, Datagram datagram) throws java.io.IOException
A listener is started for the created UDP datagram socket. This listener will exist for this given time and handle incoming UDP messages for the created UDP datagram socket.
An incoming UDP message will be forwarded to the given UDPDatagramHandler which can
handle the UDP datagram packet.
The listener should be closed with the close() method.
dstAddress - destination address of the UDP datagram packet.dstPort - destination port of the UDP datagram packet.data - the byte array which contains the data.len - the length of bytes inside the byte array which should be sent.handler - this handler will handle the incoming UDP datagram packets.java.io.IOExceptionpublic void close()
throws java.io.IOException
A listener is started if the method #send(String, int, byte[], int,
UDPDatagramHandler) is used.
java.io.IOExceptionpublic void ensureOpen()
throws java.io.IOException
java.io.IOExceptionpublic boolean isClosed()
true if the client is closed and cannot be used for a request, or
false if the client can still be used.true if the client is closed and cannot be used for a request, or false if the
client can still be used.public NetworkInterface getIface()
public IPAddress getIPAddress()
public int getPort()
public boolean hasListener()
protected void timedOut()
TimedEntrytimedOut in class TimedEntry