public class DatagramSender extends Object implements NetworkSender
NetworkEndPoint.State| Modifier and Type | Method and Description |
|---|---|
static DatagramSender |
create(ProtocolFamily protocolFamily)
Creates a datagram sender.
|
InetAddress |
getLocalAddress()
Returns the local address of this end point.
|
InetSocketAddress |
getLocalEndPoint()
Returns the local end point of this sender.
|
int |
getLocalPort()
Returns the local port of this end point.
|
NetworkInterface |
getNetworkInterface()
Returns the network interface associated with this end point.
|
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.
|
DatagramSender |
withLocalAddressAndPort(InetAddress localAddress,
int localPort)
Sets the local address and port of this sender.
|
DatagramSender |
withLocalPort(int localPort)
Sets the local port of this sender.
|
DatagramSender |
withMulticast(NetworkInterface networkInterface)
Enables multicast on this sender over the given network interface.
|
DatagramSender |
withSendBufferSize(int bufferSize)
Sets the send buffer size of this sender.
|
DatagramSender |
withSenderThreadPriority(int threadPriority)
Sets the priority of the sender threads in this sender.
|
DatagramSender |
withSenderThreads(int threads)
Sets the number of the sender threads in this sender.
|
DatagramSender |
withSendRepeatCount(int repeatCount)
Sets the send repeat count of this sender.
|
DatagramSender |
withSendRepeatInterval(int repeatInterval)
Sets the send repeat interval (in milliseconds) of this sender.
|
DatagramSender |
withTimeToLive(int timeToLive)
Sets the TTL of multicast packets sent by this sender.
|
DatagramSender |
withTrafficClass(TrafficClass trafficClass)
Sets the traffic class of datagrams sent by this sender.
|
public static DatagramSender create(ProtocolFamily protocolFamily)
IllegalArgumentException - if protocolFamily is nullpublic InetAddress getLocalAddress()
NetworkEndPointgetLocalAddress in interface NetworkEndPointpublic InetSocketAddress getLocalEndPoint()
NetworkSendergetLocalEndPoint in interface NetworkSenderpublic int getLocalPort()
NetworkEndPointgetLocalPort in interface NetworkEndPointpublic NetworkInterface getNetworkInterface()
NetworkEndPointgetNetworkInterface in interface NetworkEndPointpublic 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 DatagramSender withLocalAddressAndPort(InetAddress localAddress, int localPort)
IllegalArgumentException - if localAddress is nullIllegalArgumentException - if localPort is invalidIllegalStateException - if this sender has already been startedpublic DatagramSender withLocalPort(int localPort)
IllegalArgumentException - if localPort is invalidIllegalStateException - if this sender has already been startedpublic DatagramSender withMulticast(NetworkInterface networkInterface)
IllegalArgumentException - if networkInterface is nullIllegalStateException - if this sender has already been startedpublic DatagramSender withSendBufferSize(int bufferSize)
IllegalArgumentException - if bufferSize is negativeIllegalStateException - if this sender has already been startedpublic DatagramSender withSendRepeatCount(int repeatCount)
IllegalArgumentException - if repeatCount is negativeIllegalStateException - if this sender has already been startedpublic DatagramSender withSendRepeatInterval(int repeatInterval)
IllegalArgumentException - if repeatInterval is negativeIllegalStateException - if this sender has already been startedpublic DatagramSender withSenderThreadPriority(int threadPriority)
IllegalArgumentException - if threadPriority is not validIllegalStateException - if this sender has already been startedThread.MAX_PRIORITY,
Thread.MIN_PRIORITYpublic DatagramSender withSenderThreads(int threads)
IllegalArgumentException - if threads is not positiveIllegalStateException - if this sender has already been startedpublic DatagramSender withTimeToLive(int timeToLive)
IllegalArgumentException - if timeToLive is not positiveIllegalStateException - if this sender has already been startedpublic DatagramSender withTrafficClass(TrafficClass trafficClass)
IllegalArgumentException - if trafficClass is nullIllegalStateException - if this sender has already been started