public class DatagramSenderAndReceiver extends Object implements NetworkReceiver, NetworkSender
NetworkEndPoint.State| Modifier and Type | Method and Description |
|---|---|
static DatagramSenderAndReceiver |
create(ProtocolFamily protocolFamily)
Creates a datagram sender/receiver.
|
Set<InetAddress> |
getGroups()
Returns the multicast groups associated with this sender/receiver.
|
int |
getHandlerThreadPriority()
Returns the priority of the handler threads in this sender/receiver.
|
int |
getHandlerThreads()
Returns the number of the handler threads in this sender/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 sender/receiver.
|
int |
getReceiverThreads()
Returns the number of the receiver threads in this sender/receiver.
|
int |
getSendBufferSize()
Returns the send buffer size of this sender.
|
int |
getSenderThreadPriority()
Returns the priority of the sender threads in this sender.
|
int |
getSenderThreads()
Returns the number of the sender threads in this sender.
|
int |
getSendRepeatCount()
Returns the send repeat count of this sender.
|
long |
getSendRepeatInterval()
Returns the send repeat interval (in milliseconds) of this sender.
|
NetworkEndPoint.State |
getState()
Returns the state of this end point.
|
int |
getTimeToLive()
Returns the TTL of multicast packets sent by this sender.
|
TrafficClass |
getTrafficClass()
Returns the traffic class of datagrams sent by this sender.
|
void |
sendDelayed(NetworkMessage message,
long initialDelay,
TimeUnit unit)
Sends the given message after the given initial delay.
|
void |
sendImmediately(NetworkMessage message)
Sends the given message immediately.
|
void |
start()
Starts this end point.
|
void |
stop()
Stops this end point.
|
DatagramSenderAndReceiver |
withGroups(Set<InetAddress> groups)
Sets the multicast groups associated with this sender/receiver.
|
DatagramSenderAndReceiver |
withHandlerThreadPriority(int threadPriority)
Sets the priority of the handler threads in this sender/receiver.
|
DatagramSenderAndReceiver |
withHandlerThreads(int threads)
Sets the number of the handler threads in this sender/receiver.
|
DatagramSenderAndReceiver |
withLocalAddressAndPort(InetAddress localAddress,
int localPort)
Sets the local address and port of this sender/receiver.
|
DatagramSenderAndReceiver |
withLocalPort(int localPort)
Sets the local port of this sender/receiver.
|
DatagramSenderAndReceiver |
withMessageConsumer(Consumer<NetworkMessage> messageConsumer)
Sets the message consumer of this sender/receiver.
|
DatagramSenderAndReceiver |
withMulticast(NetworkInterface networkInterface)
Enables multicast on this sender/receiver over the given network interface.
|
DatagramSenderAndReceiver |
withNetworkInterface(NetworkInterface networkInterface)
Sets the network interface associated with this sender/receiver.
|
DatagramSenderAndReceiver |
withReceiveBufferSize(int bufferSize)
Sets the receive buffer size of this sender/receiver.
|
DatagramSenderAndReceiver |
withReceiverThreadPriority(int threadPriority)
Sets the priority of the receiver threads in this receiver.
|
DatagramSenderAndReceiver |
withReceiverThreads(int threads)
Sets the number of the receiver threads in this receiver.
|
DatagramSenderAndReceiver |
withSendBufferSize(int bufferSize)
Sets the send buffer size of this sender/receiver.
|
DatagramSenderAndReceiver |
withSenderThreadPriority(int threadPriority)
Sets the priority of the sender threads in this sender/receiver.
|
DatagramSenderAndReceiver |
withSenderThreads(int threads)
Sets the number of the sender threads in this sender/receiver.
|
DatagramSenderAndReceiver |
withSendRepeatCount(int repeatCount)
Sets the send repeat count of this sender/receiver.
|
DatagramSenderAndReceiver |
withSendRepeatInterval(int repeatInterval)
Sets the send repeat interval (in milliseconds) of this sender/receiver.
|
DatagramSenderAndReceiver |
withTimeToLive(int timeToLive)
Sets the TTL of multicast packets sent by this sender/receiver.
|
DatagramSenderAndReceiver |
withTrafficClass(TrafficClass trafficClass)
Sets the traffic class of datagrams sent by this sender/receiver.
|
public static DatagramSenderAndReceiver 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 NetworkReceivergetLocalEndPoint in interface NetworkSenderpublic int getLocalPort()
NetworkEndPointgetLocalPort in interface NetworkEndPointpublic NetworkInterface getNetworkInterface()
NetworkEndPointgetNetworkInterface in interface NetworkEndPointpublic int getReceiveBufferSize()
NetworkReceivergetReceiveBufferSize in interface NetworkReceiverpublic int getReceiverThreadPriority()
public int getReceiverThreads()
public int getSendBufferSize()
NetworkSendergetSendBufferSize in interface NetworkSenderpublic int getSendRepeatCount()
public long getSendRepeatInterval()
public int getSenderThreadPriority()
public int getSenderThreads()
public NetworkEndPoint.State getState()
NetworkEndPointgetState in interface NetworkEndPointpublic int getTimeToLive()
public TrafficClass getTrafficClass()
public void sendDelayed(NetworkMessage message, long initialDelay, TimeUnit unit)
NetworkSendersendDelayed in interface NetworkSenderpublic void sendImmediately(NetworkMessage message)
NetworkSendersendImmediately in interface NetworkSenderpublic void start()
throws IOException
NetworkEndPointstart in interface NetworkEndPointIOExceptionpublic void stop()
NetworkEndPointstop in interface NetworkEndPointpublic DatagramSenderAndReceiver withHandlerThreadPriority(int threadPriority)
IllegalArgumentException - if threadPriority is not validIllegalStateException - if this sender/receiver has already been startedThread.MAX_PRIORITY,
Thread.MIN_PRIORITYpublic DatagramSenderAndReceiver withGroups(Set<InetAddress> groups)
IllegalArgumentException - if groups are nullIllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withHandlerThreads(int threads)
IllegalArgumentException - if threads is not positiveIllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withLocalAddressAndPort(InetAddress localAddress, int localPort)
IllegalArgumentException - if localAddress is nullIllegalArgumentException - if localPort is invalidIllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withLocalPort(int localPort)
IllegalArgumentException - if localPort is invalidIllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withMessageConsumer(Consumer<NetworkMessage> messageConsumer)
IllegalArgumentException - if messageConsumer is nullIllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withMulticast(NetworkInterface networkInterface)
IllegalArgumentException - if networkInterface is nullIllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withNetworkInterface(NetworkInterface networkInterface)
IllegalArgumentException - if networkInterface is nullIllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withReceiveBufferSize(int bufferSize)
IllegalArgumentException - if bufferSize is negativeIllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withReceiverThreadPriority(int threadPriority)
IllegalArgumentException - if threadPriority is not validIllegalStateException - if this receiver has already been startedThread.MAX_PRIORITY,
Thread.MIN_PRIORITYpublic DatagramSenderAndReceiver withReceiverThreads(int threads)
IllegalArgumentException - if threads is not positiveIllegalStateException - if this receiver has already been startedpublic DatagramSenderAndReceiver withSendBufferSize(int bufferSize)
IllegalArgumentException - if bufferSize is negativeIllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withSendRepeatCount(int repeatCount)
IllegalArgumentException - if repeatCount is negativeIllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withSendRepeatInterval(int repeatInterval)
IllegalArgumentException - if repeatInterval is negativeIllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withSenderThreadPriority(int threadPriority)
IllegalArgumentException - if threadPriority is not validIllegalStateException - if this sender/receiver has already been startedThread.MAX_PRIORITY,
Thread.MIN_PRIORITYpublic DatagramSenderAndReceiver withSenderThreads(int threads)
IllegalArgumentException - if threads is not positiveIllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withTimeToLive(int timeToLive)
IllegalArgumentException - if timeToLive is not positiveIllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withTrafficClass(TrafficClass trafficClass)
IllegalArgumentException - if trafficClass is nullIllegalStateException - if this sender/receiver has already been started