public class DatagramReceiver extends Object implements NetworkReceiver
NetworkEndPoint.State| Modifier and Type | Method and Description |
|---|---|
static DatagramReceiver |
create(ProtocolFamily protocolFamily)
Creates a datagram receiver.
|
Set<InetAddress> |
getGroups()
Returns the multicast groups associated with this receiver.
|
int |
getHandlerThreadPriority()
Returns the priority of the handler threads in this receiver.
|
int |
getHandlerThreads()
Returns the number of the handler threads in this receiver.
|
InetAddress |
getLocalAddress()
Returns the local address of this end point.
|
InetSocketAddress |
getLocalEndPoint()
Returns the local end point of this receiver.
|
int |
getLocalPort()
Returns the local port of this end point.
|
NetworkInterface |
getNetworkInterface()
Returns the network interface associated with this end point.
|
int |
getReceiveBufferSize()
Returns the receive buffer size of this receiver.
|
int |
getReceiverThreadPriority()
Returns the priority of the receiver threads in this receiver.
|
int |
getReceiverThreads()
Returns the number of the receiver threads in this receiver.
|
NetworkEndPoint.State |
getState()
Returns the state of this end point.
|
void |
start()
Starts this end point.
|
void |
stop()
Stops this end point.
|
DatagramReceiver |
withGroups(Set<InetAddress> groups)
Sets the multicast groups associated with this receiver.
|
DatagramReceiver |
withHandlerThreadPriority(int threadPriority)
Sets the priority of the handler threads in this receiver.
|
DatagramReceiver |
withHandlerThreads(int threads)
Sets the number of the handler threads in this receiver.
|
DatagramReceiver |
withLocalAddressAndPort(InetAddress localAddress,
int localPort)
Sets the local address and port of this receiver.
|
DatagramReceiver |
withLocalPort(int localPort)
Sets the local port of this receiver.
|
DatagramReceiver |
withMessageConsumer(Consumer<NetworkMessage> messageConsumer)
Sets the message consumer of this receiver.
|
DatagramReceiver |
withNetworkInterface(NetworkInterface networkInterface)
Sets the network interface associated with this receiver.
|
DatagramReceiver |
withReceiveBufferSize(int bufferSize)
Sets the receive buffer size of this receiver.
|
DatagramReceiver |
withReceiverThreadPriority(int threadPriority)
Sets the priority of the receiver threads in this receiver.
|
DatagramReceiver |
withReceiverThreads(int threads)
Sets the number of the receiver threads in this receiver.
|
public static DatagramReceiver create(ProtocolFamily protocolFamily)
IllegalArgumentException - if protocolFamily is nullpublic Set<InetAddress> getGroups()
public int getHandlerThreadPriority()
public int getHandlerThreads()
public InetAddress getLocalAddress()
NetworkEndPointgetLocalAddress in interface NetworkEndPointpublic InetSocketAddress getLocalEndPoint()
NetworkReceivergetLocalEndPoint in interface NetworkReceiverpublic int getLocalPort()
NetworkEndPointgetLocalPort in interface NetworkEndPointpublic NetworkInterface getNetworkInterface()
NetworkEndPointgetNetworkInterface in interface NetworkEndPointpublic int getReceiveBufferSize()
NetworkReceivergetReceiveBufferSize in interface NetworkReceiverpublic int getReceiverThreadPriority()
public int getReceiverThreads()
public NetworkEndPoint.State getState()
NetworkEndPointgetState in interface NetworkEndPointpublic void start()
throws IOException
NetworkEndPointstart in interface NetworkEndPointIOExceptionpublic void stop()
NetworkEndPointstop in interface NetworkEndPointpublic DatagramReceiver withHandlerThreadPriority(int threadPriority)
IllegalArgumentException - if threadPriority is not validIllegalStateException - if this receiver has already been startedThread.MAX_PRIORITY,
Thread.MIN_PRIORITYpublic DatagramReceiver withGroups(Set<InetAddress> groups)
IllegalArgumentException - if groups are nullIllegalStateException - if this receiver has already been startedpublic DatagramReceiver withHandlerThreads(int threads)
IllegalArgumentException - if threads is not positiveIllegalStateException - if this receiver has already been startedpublic DatagramReceiver withLocalAddressAndPort(InetAddress localAddress, int localPort)
IllegalArgumentException - if localAddress is nullIllegalArgumentException - if localPort is invalidIllegalStateException - if this receiver has already been startedpublic DatagramReceiver withLocalPort(int localPort)
IllegalArgumentException - if localPort is invalidIllegalStateException - if this receiver has already been startedpublic DatagramReceiver withMessageConsumer(Consumer<NetworkMessage> messageConsumer)
IllegalArgumentException - if messageConsumer is nullIllegalStateException - if this receiver has already been startedpublic DatagramReceiver withNetworkInterface(NetworkInterface networkInterface)
IllegalArgumentException - if networkInterface is nullIllegalStateException - if this receiver has already been startedpublic DatagramReceiver withReceiveBufferSize(int bufferSize)
IllegalArgumentException - if bufferSize is negativeIllegalStateException - if this receiver has already been startedpublic DatagramReceiver withReceiverThreadPriority(int threadPriority)
IllegalArgumentException - if threadPriority is not validIllegalStateException - if this receiver has already been startedThread.MAX_PRIORITY,
Thread.MIN_PRIORITYpublic DatagramReceiver withReceiverThreads(int threads)
IllegalArgumentException - if threads is not positiveIllegalStateException - if this receiver has already been started