NetworkEndPoint, NetworkReceiver, NetworkSenderpublic class DatagramSenderAndReceiver extends java.lang.Object implements NetworkReceiver, NetworkSender
NetworkEndPoint.State| Modifier and Type | Method | Description |
|---|---|---|
static DatagramSenderAndReceiver |
create(java.net.ProtocolFamily protocolFamily) |
Creates a datagram sender/receiver.
|
java.util.Set<java.net.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.
|
java.net.InetAddress |
getLocalAddress() |
Returns the local address of this end point.
|
java.net.InetSocketAddress |
getLocalEndPoint() |
Returns the local end point of this receiver.
|
int |
getLocalPort() |
Returns the local port of this end point.
|
java.net.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,
java.util.concurrent.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(java.util.Set<java.net.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(java.net.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(java.util.function.Consumer<NetworkMessage> messageConsumer) |
Sets the message consumer of this sender/receiver.
|
DatagramSenderAndReceiver |
withMulticast(java.net.NetworkInterface networkInterface) |
Enables multicast on this sender/receiver over the given network interface.
|
DatagramSenderAndReceiver |
withNetworkInterface(java.net.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(java.net.ProtocolFamily protocolFamily)
java.lang.IllegalArgumentException - if protocolFamily is nullpublic java.util.Set<java.net.InetAddress> getGroups()
public int getHandlerThreadPriority()
public int getHandlerThreads()
public java.net.InetAddress getLocalAddress()
NetworkEndPointgetLocalAddress in interface NetworkEndPointpublic java.net.InetSocketAddress getLocalEndPoint()
NetworkReceivergetLocalEndPoint in interface NetworkReceivergetLocalEndPoint in interface NetworkSenderpublic int getLocalPort()
NetworkEndPointgetLocalPort in interface NetworkEndPointpublic java.net.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, java.util.concurrent.TimeUnit unit)
NetworkSendersendDelayed in interface NetworkSenderpublic void sendImmediately(NetworkMessage message)
NetworkSendersendImmediately in interface NetworkSenderpublic void start()
throws java.io.IOException
NetworkEndPointstart in interface NetworkEndPointjava.io.IOExceptionpublic void stop()
NetworkEndPointstop in interface NetworkEndPointpublic DatagramSenderAndReceiver withHandlerThreadPriority(int threadPriority)
java.lang.IllegalArgumentException - if threadPriority is not validjava.lang.IllegalStateException - if this sender/receiver has already been startedThread.MAX_PRIORITY,
Thread.MIN_PRIORITYpublic DatagramSenderAndReceiver withGroups(java.util.Set<java.net.InetAddress> groups)
java.lang.IllegalArgumentException - if groups are nulljava.lang.IllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withHandlerThreads(int threads)
java.lang.IllegalArgumentException - if threads is not positivejava.lang.IllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withLocalAddressAndPort(java.net.InetAddress localAddress, int localPort)
java.lang.IllegalArgumentException - if localAddress is nulljava.lang.IllegalArgumentException - if localPort is invalidjava.lang.IllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withLocalPort(int localPort)
java.lang.IllegalArgumentException - if localPort is invalidjava.lang.IllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withMessageConsumer(java.util.function.Consumer<NetworkMessage> messageConsumer)
java.lang.IllegalArgumentException - if messageConsumer is nulljava.lang.IllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withMulticast(java.net.NetworkInterface networkInterface)
java.lang.IllegalArgumentException - if networkInterface is nulljava.lang.IllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withNetworkInterface(java.net.NetworkInterface networkInterface)
java.lang.IllegalArgumentException - if networkInterface is nulljava.lang.IllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withReceiveBufferSize(int bufferSize)
java.lang.IllegalArgumentException - if bufferSize is negativejava.lang.IllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withReceiverThreadPriority(int threadPriority)
java.lang.IllegalArgumentException - if threadPriority is not validjava.lang.IllegalStateException - if this receiver has already been startedThread.MAX_PRIORITY,
Thread.MIN_PRIORITYpublic DatagramSenderAndReceiver withReceiverThreads(int threads)
java.lang.IllegalArgumentException - if threads is not positivejava.lang.IllegalStateException - if this receiver has already been startedpublic DatagramSenderAndReceiver withSendBufferSize(int bufferSize)
java.lang.IllegalArgumentException - if bufferSize is negativejava.lang.IllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withSendRepeatCount(int repeatCount)
java.lang.IllegalArgumentException - if repeatCount is negativejava.lang.IllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withSendRepeatInterval(int repeatInterval)
java.lang.IllegalArgumentException - if repeatInterval is negativejava.lang.IllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withSenderThreadPriority(int threadPriority)
java.lang.IllegalArgumentException - if threadPriority is not validjava.lang.IllegalStateException - if this sender/receiver has already been startedThread.MAX_PRIORITY,
Thread.MIN_PRIORITYpublic DatagramSenderAndReceiver withSenderThreads(int threads)
java.lang.IllegalArgumentException - if threads is not positivejava.lang.IllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withTimeToLive(int timeToLive)
java.lang.IllegalArgumentException - if timeToLive is not positivejava.lang.IllegalStateException - if this sender/receiver has already been startedpublic DatagramSenderAndReceiver withTrafficClass(TrafficClass trafficClass)
java.lang.IllegalArgumentException - if trafficClass is nulljava.lang.IllegalStateException - if this sender/receiver has already been started