mdw.sandStorm.lib.aSocket
Class AMcastSocket
java.lang.Object
|
+--mdw.sandStorm.core.SimpleSink
|
+--mdw.sandStorm.lib.aSocket.AUdpSocket
|
+--mdw.sandStorm.lib.aSocket.AMcastSocket
- All Implemented Interfaces:
- ProfilableIF, SinkIF
- public class AMcastSocket
- extends AUdpSocket
This is a simple extension of the AMcastSocket class, which creates
uses a NonblockingMulticastSocket as the underlying socket, rather
than a NonblockingDatagramSocket.
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.
FIXME: possibly change the behavior of this class, to mimic more
normal connected behavior? This would simply involve _not_ doing
the connect when requested, but instead keeping track of the
outbound address to use, and filling in all blank outbound packets
with it. Would this break expected semantics somewhere?
- Author:
- Rob von Behren
- See Also:
NonblockingMulticastSocket
,
AMcastSocket
Constructor Summary |
AMcastSocket(java.net.InetAddress localaddr,
int localport,
SinkIF compQ,
int maxPacketSize,
int writeClogThreshold)
Create a socket bound to the given local address and local port. |
AMcastSocket(int localport,
SinkIF compQ)
Create a socket bound to the given local port. |
Method Summary |
java.net.InetAddress |
getInterface()
set the multicast interface |
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)
Set the looping state of the Multicast socket. |
void |
setInterface(java.net.InetAddress addr)
set the multicast interface |
void |
setTimeToLive(int ttl)
set the multicast ttl |
Methods inherited from class mdw.sandStorm.lib.aSocket.AUdpSocket |
close, connect, disconnect, enqueue_lossy, enqueue_many, enqueue, flush, getAddress, getLocalAddress, getLocalPort, getPort, getSequenceNumber, profileSize, size, startReader, startReader |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
AMcastSocket
public AMcastSocket(int localport,
SinkIF compQ)
throws java.io.IOException
- Create a socket bound to the given local port.
AMcastSocket
public AMcastSocket(java.net.InetAddress localaddr,
int localport,
SinkIF compQ,
int maxPacketSize,
int writeClogThreshold)
throws java.io.IOException
- Create a socket bound to the given local address and local port.
- Parameters:
maxPacketSize
- The maximum size, in bytes, of packets that
this socket will attempt to receive. The default is
DEFAULT_MAX_PACKETSIZE, which is 16 KBytes.writeClogThreshold
- The maximum number of outstanding writes
on this socket before a SinkCloggedEvent is pushed to the
connection's completion queue. This is effectively the maximum depth
threshold for this connection's SinkIF. The default value is -1, which
indicates that no SinkCloggedEvents will be generated.
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
setTimeToLive
public void setTimeToLive(int ttl)
throws java.io.IOException
- set the multicast ttl
getTimeToLive
public int getTimeToLive()
throws java.io.IOException
- get the multicast ttl
setInterface
public void setInterface(java.net.InetAddress addr)
throws java.io.IOException
- set the multicast interface
getInterface
public java.net.InetAddress getInterface()
throws java.io.IOException
- set the multicast interface
seeLocalMessages
public void seeLocalMessages(boolean state)
throws java.io.IOException
- Set the looping state of the Multicast socket. If state==true,
the socket will receive packets it sends out. If false, it will
not.
NOTE: This doesn't work like you would probably expect it to!!
See the NonblockingMulticastSocket docs for more info.
- See Also:
NonblockingMulticastSocket