mdw.nbio
Class NonblockingMulticastSocket
java.lang.Object
|
+--java.net.DatagramSocket
|
+--mdw.nbio.NonblockingDatagramSocket
|
+--mdw.nbio.NonblockingMulticastSocket
- All Implemented Interfaces:
- Selectable
- public class NonblockingMulticastSocket
- extends NonblockingDatagramSocket
NonblockingMulticastSocket provides non-blocking multicast datagram I/O.
NOTE: packets cannot be received on a socket once connect() is
called, due to the semantics of connect() for multicast sockets.
Instead, applications should generally use joinGroup(), and then
explicitly specify the group address as the destination in all the
outbound packets.
Fields inherited from class java.net.DatagramSocket |
connected, connectedAddress, connectedPort, factory, implClass |
Method Summary |
java.net.InetAddress |
getInterface()
Get the interface associated with this multicast socket |
int |
getTimeToLive()
get the multicast ttl |
void |
joinGroup(java.net.InetAddress addr)
Join a multicast group |
void |
leaveGroup(java.net.InetAddress addr)
Leave a multicast group |
void |
seeLocalMessages(boolean state)
This sets the state of the IP_MULTICAST_LOOP option on the
underlying socket. |
void |
setInterface(java.net.InetAddress addr)
Set the interface associated with this socket |
void |
setTimeToLive(int ttl)
set the time to live |
Methods inherited from class mdw.nbio.NonblockingDatagramSocket |
, close, connect, connect, disconnect, getInetAddress, getLocalAddress, getLocalPort, getPort, getReceiveBufferSize, getSendBufferSize, nbReceive, nbReceive, nbSend, nbSend, nbSend, receive, send, setReceiveBufferSize, setSendBufferSize |
Methods inherited from class java.net.DatagramSocket |
create, getSoTimeout, setDatagramSocketImplFactory, setSoTimeout |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
multicast_interface
java.net.InetAddress multicast_interface
multicast_ttl
int multicast_ttl
NonblockingMulticastSocket
public NonblockingMulticastSocket()
throws java.io.IOException
- Create a NonblockingMulticastSocket bound to any available port.
NonblockingMulticastSocket
public NonblockingMulticastSocket(int port)
throws java.io.IOException
NonblockingMulticastSocket
public NonblockingMulticastSocket(int port,
java.net.InetAddress laddr)
throws java.io.IOException
- Create a NonblockingMulticastSocket bound to the given port and
the given local address.
joinGroup
public void joinGroup(java.net.InetAddress addr)
throws java.io.IOException
- Join a multicast group
leaveGroup
public void leaveGroup(java.net.InetAddress addr)
throws java.io.IOException
- Leave a multicast group
getTimeToLive
public int getTimeToLive()
throws java.io.IOException
- get the multicast ttl
setTimeToLive
public void setTimeToLive(int ttl)
throws java.io.IOException
- set the time to live
getInterface
public java.net.InetAddress getInterface()
- Get the interface associated with this multicast socket
setInterface
public void setInterface(java.net.InetAddress addr)
throws java.io.IOException
- Set the interface associated with this socket
seeLocalMessages
public void seeLocalMessages(boolean state)
throws java.io.IOException
- This sets the state of the IP_MULTICAST_LOOP option on the
underlying socket. If state==true, the socket will receive
packets it sends out. If false, it will not.
NOTE: The behavior of this is somewhat strange for two multicast
listeners on the same physical machine. Ideally, this should be
an incoming filter - each socket should throw out packets that it
sent out, and not deliver them to the application.
Unfortunately, this instead seems to be an outbound filter - all
packets sent out on a socket with IP_MULTICAST_LOOP turned off
will be invisible to all sockets on the local machine -
regardless of whether or not these other sockets have specified
IP_MULTICAST_LOOP=false.