com.sun.multicast.reliable.transport.tram
Class TRAMPacketSocket

java.lang.Object
  |
  +--com.sun.multicast.reliable.transport.tram.TRAMPacketSocket
All Implemented Interfaces:
RMPacketSocket

public class TRAMPacketSocket
extends java.lang.Object
implements RMPacketSocket

The TRAMPacketSocket implements RMPacketSocket Interface. TRAMPacketSocket allows applications to send and receive packets, set the interface over which data is to be sent, and close the socket after completion or to abort the connection before the session ends.


Constructor Summary
TRAMPacketSocket()
           
TRAMPacketSocket(TRAMSimulator simulator)
           
 
Method Summary
 void abort()
          Abort the current connection.
 void close()
          The close method shuts down the socket after flushing the transmit queue.
 java.net.InetAddress getInterface()
          The getInterface method returns the InetAddress of the local port that data is transmitted on if other than the default.
 int getMaxLength()
          Gets the maximum amount of data that can be sent in a DatagramPacket over this socket.
 long getReceiverMaxDataRate()
          Gets the Max receiver rate at the transport profile associated with this socket.
 RMStatistics getRMStatistics()
          This method returns a clone of the Statistics block in use in this socket.
 TransportProfile getTransportProfile()
          This method returns a clone of the TransportProfile in use in this socket.
 void monitor()
          Lets the application monitor the session without receiving packets.
 java.net.DatagramPacket receive()
          The receive method returns the next RMDatagramPacket.
 void send(java.net.DatagramPacket dp)
          The send method transmits the DatagramPacket over the multicast connection.
 int send(java.net.DatagramPacket dp, int fb)
          This send method transmits the DatagramPacket over the multicast connection.
 void setInterface(java.net.InetAddress ia)
          Set the interface which data will be transmitted on.
 void setReceiverMaxDataRate(long rate)
          Sets the Max receiver rate at the transport profile associated with this socket.
 void simulateMulticastPacketReceive(java.net.DatagramPacket dp)
          Injects the multicast packet into the input dispatcher
 void simulateUnicastPacketReceive(java.net.DatagramPacket dp)
          Injects the unicast packet into the input dispatcher
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TRAMPacketSocket

public TRAMPacketSocket()

TRAMPacketSocket

public TRAMPacketSocket(TRAMSimulator simulator)
Method Detail

getInterface

public java.net.InetAddress getInterface()
                                  throws java.net.SocketException
The getInterface method returns the InetAddress of the local port that data is transmitted on if other than the default.
Specified by:
getInterface in interface RMPacketSocket
Following copied from interface: com.sun.multicast.reliable.transport.RMPacketSocket
Returns:
the address of the network interface for outgoing data.
Throws:
java.net.SocketException - if a socket-related error occurs
UnsupportedException - if the transport does not support getting the interface
RMException - if a reliable-multicast-related exception occurs

setInterface

public void setInterface(java.net.InetAddress ia)
                  throws java.net.SocketException
Set the interface which data will be transmitted on. This is useful on systems with multiple network interfaces.
Specified by:
setInterface in interface RMPacketSocket
Parameters:
ia - the InetAddress of the interface to transmit data on.

send

public void send(java.net.DatagramPacket dp)
          throws java.io.IOException
The send method transmits the DatagramPacket over the multicast connection.
Specified by:
send in interface RMPacketSocket
Parameters:
dp - the DatagramPacket to be sent.
Throws:
java.io.IOException - is raised if an error occurs sending the data. We need to add the TRAM header on top of the passed in packet... hence we need to create another datagram packet large enough to hold the TRAM header plus the passed in data and then hand it over to the lower layer to transmit it.

send

public int send(java.net.DatagramPacket dp,
                int fb)
         throws java.io.IOException
This send method transmits the DatagramPacket over the multicast connection. This is the version of send that allows application to specify a forgetBefore sequence number.
Parameters:
dp - the DatagramPacket to be sent.
fb - the forgetBeforeSeqNum to be included in packet.
Returns:
int the assigned sequence number for dp.
Throws:
java.io.IOException - is raised if an error occurs sending the data. We need to add the TRAM header on top of the passed in packet... hence we need to create another datagram packet large enough to hold the TRAM header plus the passed in data and then hand it over to the lower layer to transmit it.

receive

public java.net.DatagramPacket receive()
                                throws java.io.IOException,
                                       SessionDoneException,
                                       IrrecoverableDataException,
                                       SessionDownException,
                                       MemberPrunedException
The receive method returns the next RMDatagramPacket.
Specified by:
receive in interface RMPacketSocket
Throws:
java.io.IOException - is thrown if an error occurs retrieving the data.
SessionDoneException - if the end of the data stream is detected.
IrrecoverableDataException - when a packet is lost in transmission and cannot be recovered.
SessionDownException - when the sender has left the multicast group.

monitor

public void monitor()
             throws java.io.IOException,
                    SessionDoneException,
                    IrrecoverableDataException,
                    SessionDownException
Lets the application monitor the session without receiving packets. When the session is done, or aborts, an exception is generated.

abort

public void abort()
Abort the current connection. Any data still waiting to be transmitted is dropped. The connection is shutdown and this socket is closed.
Specified by:
abort in interface RMPacketSocket

close

public void close()
The close method shuts down the socket after flushing the transmit queue. All data previously transmitted will be handed to the network prior to tearing down the connection.
Specified by:
close in interface RMPacketSocket

getMaxLength

public int getMaxLength()
Gets the maximum amount of data that can be sent in a DatagramPacket over this socket.
Specified by:
getMaxLength in interface RMPacketSocket
Returns:
the maximum allowed value for DatagramPacket.getLength()

getTransportProfile

public TransportProfile getTransportProfile()
This method returns a clone of the TransportProfile in use in this socket.
Specified by:
getTransportProfile in interface RMPacketSocket
Returns:
a cloned TransportProfile

getRMStatistics

public RMStatistics getRMStatistics()
This method returns a clone of the Statistics block in use in this socket.
Specified by:
getRMStatistics in interface RMPacketSocket
Returns:
a cloned TRAM statistics block

simulateMulticastPacketReceive

public void simulateMulticastPacketReceive(java.net.DatagramPacket dp)
Injects the multicast packet into the input dispatcher
Parameters:
packet - the multicast datagram packet

simulateUnicastPacketReceive

public void simulateUnicastPacketReceive(java.net.DatagramPacket dp)
Injects the unicast packet into the input dispatcher
Parameters:
packet - the unicast datagram packet

setReceiverMaxDataRate

public void setReceiverMaxDataRate(long rate)
Sets the Max receiver rate at the transport profile associated with this socket.
Parameters:
long - max receiver data rate

getReceiverMaxDataRate

public long getReceiverMaxDataRate()
Gets the Max receiver rate at the transport profile associated with this socket.
Returns:
long max receiver data rate


JavaTM Reliable MulticastTM Service version 1.1
Copyright (c) 2001, Sun Microsystems Laboratories, All rights reserved.