public class UDPServer
extends java.lang.Object
| Constructor and Description |
|---|
UDPServer() |
| Modifier and Type | Method and Description |
|---|---|
static void |
close(IPAddress ipAddress,
int port,
NetworkInterface iface)
Closes the created UDP connection listener by address and port.
|
static DatagramSocket |
getDatagramSocket(IPAddress ipAddress,
int port,
NetworkInterface iface) |
static int |
open(IPAddress ipAddress,
int port,
NetworkInterface iface,
AddressFilter filter,
UDPDatagramHandler handler,
java.lang.String comManId,
boolean forceMulticastSocket)
Opens a datagram socket for a given address and port.
|
static void |
send(IPAddress localAddress,
int localPort,
NetworkInterface iface,
Datagram datagram)
Sends a datagram packet with the given address and port.
|
public static int open(IPAddress ipAddress, int port, NetworkInterface iface, AddressFilter filter, UDPDatagramHandler handler, java.lang.String comManId, boolean forceMulticastSocket) throws java.io.IOException
This will start a new UDP listener for the given address and port. This listener will pass-through the incoming UDP datagram to the given UDP handler.
address - the address.port - the port.ifaceName - handler - the UDP datagram handler which will handle the incoming UDP datagram.java.io.IOException - will throw an IO exception if the datagram socket could not be opened.public static void close(IPAddress ipAddress, int port, NetworkInterface iface) throws java.io.IOException
address - the address.port - the port.java.io.IOExceptionpublic static void send(IPAddress localAddress, int localPort, NetworkInterface iface, Datagram datagram) throws java.io.IOException
address - the source address.localPort - the source port.dstAddress - the destination address of the datagram packet.dstPort - the destination port of the datagram packet.data - the content of the datagram packet.len - the length of the datagram packet.java.io.IOExceptionpublic static DatagramSocket getDatagramSocket(IPAddress ipAddress, int port, NetworkInterface iface)