public class UDP extends TP
The following properties are read by the UDP protocol:
Modifier and Type | Class and Description |
---|---|
class |
UDP.PacketReceiver |
TP.Bundler, TP.ProtocolAdapter
Modifier and Type | Field and Description |
---|---|
protected boolean |
disable_loopback |
protected boolean |
ip_mcast |
protected int |
ip_ttl |
protected IpAddress |
mcast_addr
The multicast address (mcast address and port) this member uses
|
protected InetAddress |
mcast_group_addr |
protected int |
mcast_port |
protected UDP.PacketReceiver |
mcast_receiver
Runnable to receive multicast packets
|
protected int |
mcast_recv_buf_size |
protected int |
mcast_send_buf_size |
protected MulticastSocket |
mcast_sock
IP multicast socket for receiving multicast packets
|
protected DatagramSocket |
sock
Socket used for
sending unicast and multicast packets and
receiving unicast packets
The address of this socket will be our local address (local_addr)
|
protected int |
tos
Traffic class for sending unicast and multicast datagrams.
|
protected UDP.PacketReceiver |
ucast_receiver
Runnable to receive unicast packets
|
protected int |
ucast_recv_buf_size |
protected int |
ucast_send_buf_size |
bind_addr, bind_interface_str, bind_port, bundler, bundler_capacity, bundler_type, can_bind_to_mcast_addr, channel_name, connect_count, connectLock, default_thread_factory, diag_handler, diagnostics_addr, diagnostics_port, discard_incompatible_packets, enable_bundling, enable_diagnostics, enable_unicast_bundling, external_addr, external_port, f, global_thread_factory, header, last_discovery_request, LIST, local_addr, log_discard_msgs, logical_addr_cache, logical_addr_cache_expiration, logical_addr_cache_max_size, loopback, max_bundle_size, max_bundle_timeout, members, MULTICAST, num_bytes_received, num_bytes_sent, num_incoming_msgs_received, num_msgs_received, num_msgs_sent, num_oob_msgs_received, OOB, oob_thread_factory, oob_thread_pool, oob_thread_pool_enabled, oob_thread_pool_keep_alive_time, oob_thread_pool_max_threads, oob_thread_pool_min_threads, oob_thread_pool_queue, oob_thread_pool_queue_enabled, oob_thread_pool_queue_max_size, pool_thread_group, port_range, preregistered_probe_handlers, print_function, receive_interfaces, receive_on_all_interfaces, singleton_name, socket_factory, thread_naming_pattern, thread_pool, thread_pool_enabled, thread_pool_keep_alive_time, thread_pool_max_threads, thread_pool_min_threads, thread_pool_queue, thread_pool_queue_enabled, thread_pool_queue_max_size, thread_pool_rejection_policy, tick_time, timer, timer_keep_alive_time, timer_max_threads, timer_min_threads, timer_queue_max_size, timer_rejection_policy, timer_thread_factory, timer_type, up_prots, wheel_size, who_has_cache
Constructor and Description |
---|
UDP() |
Modifier and Type | Method and Description |
---|---|
protected void |
_send(InetAddress dest,
int port,
boolean mcast,
byte[] data,
int offset,
int length) |
protected void |
bindToInterfaces(List<NetworkInterface> interfaces,
MulticastSocket s,
InetAddress mcastAddr) |
protected void |
closeUnicastSocket() |
protected DatagramSocket |
createDatagramSocketWithBindPort()
Creates a DatagramSocket when bind_port > 0.
|
protected DatagramSocket |
createEphemeralDatagramSocket()
Creates a DatagramSocket with a random port.
|
protected IpAddress |
createLocalAddress() |
protected void |
createSockets()
Create UDP sender and receiver sockets.
|
void |
destroy()
This method is called on a
Channel.close() . |
protected void |
destroySockets() |
protected String |
dumpSocketInfo() |
String |
getInfo() |
InetAddress |
getMulticastAddress() |
int |
getMulticastPort() |
int |
getMulticastTTL()
Getter for current multicast TTL
|
protected PhysicalAddress |
getPhysicalAddress() |
protected void |
handleConfigEvent(Map<String,Object> map) |
protected void |
handleConnect() |
protected void |
handleDisconnect() |
void |
sendMulticast(byte[] data,
int offset,
int length)
Send to all members in the group.
|
void |
sendUnicast(PhysicalAddress dest,
byte[] data,
int offset,
int length)
Send a unicast to 1 member.
|
protected void |
setBufferSize(DatagramSocket sock,
int send_buf_size,
int recv_buf_size) |
void |
setMaxBundleSize(int size) |
void |
setMcastPort(int mcast_port) |
void |
setMulticastAddress(InetAddress addr) |
void |
setMulticastPort(int mcast_port) |
void |
setMulticastTTL(int ttl)
Set the ttl for multicast socket
|
void |
start()
Creates the unicast and multicast sockets and starts the unicast and multicast receiver threads
|
void |
stop()
This method is called on a
Channel.disconnect() . |
boolean |
supportsMulticasting()
Usually, src addresses are nulled, and the receiver simply sets them to
the address of the sender.
|
addPhysicalAddressToCache, clearLogicalAddressCache, createThreadPool, dispatchToThreadPool, doSend, down, dumpTimerTasks, evictLogicalAddressCache, fetchLocalAddresses, getBindAddress, getBindPort, getBundlerBufferSize, getDefaultThreadPool, getDefaultThreadPoolThreadFactory, getLogDiscardMessages, getMaxBundleSize, getMaxBundleTimeout, getNumBytesReceived, getNumBytesSent, getNumMessagesReceived, getNumMessagesSent, getNumThreads, getNumTimerTasks, getOOBMaxQueueSize, getOOBMessages, getOOBPoolSize, getOOBQueueSize, getOOBThreadPool, getOOBThreadPoolKeepAliveTime, getOOBThreadPoolMaxThreads, getOOBThreadPoolMinThreads, getOOBThreadPoolThreadFactory, getPhysicalAddressFromCache, getPoolThreadGroup, getPortRange, getReceiveInterfaces, getRegularMaxQueueSize, getRegularMessages, getRegularPoolSize, getRegularQueueSize, getSingletonName, getSocketFactory, getThreadFactory, getThreadNamingPattern, getThreadPoolKeepAliveTime, getThreadPoolMaxThreads, getThreadPoolMinThreads, getTimer, getTimerClass, getTimerKeepAliveTime, getTimerMaxThreads, getTimerMinThreads, getTimerQueueSize, getTimerThreadFactory, getTimerThreads, getUpProtocols, handleDownEvent, init, isDefaulThreadPoolEnabled, isDiscardIncompatiblePackets, isEnableBundling, isEnableUnicastBundling, isLoopback, isMulticastCapable, isOOBThreadPoolEnabled, isReceiveOnAllInterfaces, isSingleton, passMessageUp, passToAllUpProtocols, printLogicalAddressCache, readMessage, readMessageList, receive, registerLocalAddress, registerProbeHandler, removeLogicalAddressFromCache, resetStats, send, sendToAllPhysicalAddresses, sendToSingleMember, setBindAddress, setBindPort, setBindToAllInterfaces, setDefaultThreadPool, setDefaultThreadPoolThreadFactory, setDiagnosticsHandler, setDiscardIncompatiblePackets, setEnableBundling, setEnableUnicastBundling, setInAllThreadFactories, setLogDiscardMessages, setLoopback, setMaxBundleTimeout, setOOBRejectionPolicy, setOOBThreadPool, setOOBThreadPoolKeepAliveTime, setOOBThreadPoolMaxThreads, setOOBThreadPoolMinThreads, setOOBThreadPoolThreadFactory, setPortRange, setRegularRejectionPolicy, setSocketFactory, setSourceAddress, setThreadFactory, setThreadNames, setThreadPoolKeepAliveTime, setThreadPoolMaxThreads, setThreadPoolMinThreads, setThreadPoolQueueEnabled, setTimer, setTimerKeepAliveTime, setTimerMaxThreads, setTimerMinThreads, setTimerThreadFactory, shutdownThreadPool, toString, unregisterProbeHandler, unsetThreadNames, up, writeMessage, writeMessageList
dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getId, getLevel, getName, getProtocolStack, getTransport, getUpProtocol, getValue, isErgonomics, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setUpProtocol, setValue, setValues, statsEnabled
protected int tos
DatagramSocket.setTrafficClass(int)
); for details):
IPTOS_LOWCOST (0x02)
, decimal 2IPTOS_RELIABILITY (0x04)
<, decimal 4/LI>
IPTOS_THROUGHPUT (0x08)
, decimal 8IPTOS_LOWDELAY (0x10)
, decimal 16protected InetAddress mcast_group_addr
protected int mcast_port
protected boolean ip_mcast
protected int ip_ttl
protected int mcast_send_buf_size
protected int mcast_recv_buf_size
protected int ucast_send_buf_size
protected int ucast_recv_buf_size
protected boolean disable_loopback
protected IpAddress mcast_addr
protected DatagramSocket sock
protected MulticastSocket mcast_sock
protected UDP.PacketReceiver mcast_receiver
protected UDP.PacketReceiver ucast_receiver
public boolean supportsMulticasting()
supportsMulticasting
in class TP
public void setMulticastAddress(InetAddress addr)
public InetAddress getMulticastAddress()
public int getMulticastPort()
public void setMulticastPort(int mcast_port)
public void setMcastPort(int mcast_port)
public void setMulticastTTL(int ttl) throws IOException
ttl
- the time to live for the socket.IOException
public int getMulticastTTL()
public void setMaxBundleSize(int size)
setMaxBundleSize
in class TP
public void sendMulticast(byte[] data, int offset, int length) throws Exception
TP
sendMulticast
in class TP
data
- The data to be sent. This is not a copy, so don't modify itException
public void sendUnicast(PhysicalAddress dest, byte[] data, int offset, int length) throws Exception
TP
sendUnicast
in class TP
dest
- Must be a non-null unicast addressdata
- The data to be sent. This is not a copy, so don't modify itException
protected void _send(InetAddress dest, int port, boolean mcast, byte[] data, int offset, int length) throws Exception
Exception
public void start() throws Exception
start
in class TP
Exception
- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack
to fail, so Channel.connect(String)
will throw an exceptionpublic void stop()
Protocol
Channel.disconnect()
. Stops work (e.g. by closing multicast socket).
Will be called from top to bottom. This means that at the time of the method invocation the
neighbor protocol below is still working. This method will replace the
STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that
when this method is called all messages in the down queue will have been flushedpublic void destroy()
Protocol
Channel.close()
.
Does some cleanup; after the call the VM will terminateprotected void handleConnect() throws Exception
handleConnect
in class TP
Exception
protected void handleDisconnect()
handleDisconnect
in class TP
protected void createSockets() throws Exception
Exception
protected void destroySockets()
protected IpAddress createLocalAddress()
protected PhysicalAddress getPhysicalAddress()
getPhysicalAddress
in class TP
protected void bindToInterfaces(List<NetworkInterface> interfaces, MulticastSocket s, InetAddress mcastAddr)
interfaces
- Lists
- mcastAddr
- IOException
protected DatagramSocket createEphemeralDatagramSocket() throws SocketException
SocketException
protected DatagramSocket createDatagramSocketWithBindPort() throws Exception
Exception
protected void setBufferSize(DatagramSocket sock, int send_buf_size, int recv_buf_size)
protected void closeUnicastSocket()
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.