com.sun.multicast.reliable.transport.um
Class UMPacketSocket

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

public class UMPacketSocket
extends java.lang.Object
implements RMPacketSocket

An RMPacketSocket for the Unreliable Multicast transport.

The only transport-specific public methods that are added by this class are getSoTimeout and setSoTimeout, which allow a timeout to be specified for the receive method.

See Also:
RMPacketSocket

Method Summary
 void abort()
          Abort the current connection.
 void close()
          The close method shuts down the socket after flushing the transmit queue.
 long getDataRate()
           
 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.
 RMStatistics getRMStatistics()
          Returns the latest snapshot of the maintained Transport statistics block.
 int getSoTimeout()
          Return the SO_TIMEOUT setting in milliseconds.
 TransportProfile getTransportProfile()
          Return a copy of the transport profile this socket is using.
 java.net.DatagramPacket receive()
          The receive method returns the next RMDatagramPacket.
 void send(java.net.DatagramPacket dp)
          The send method transmits a DatagramPacket over the multicast connection.
 void send(java.net.DatagramPacket dp, byte ttl)
          The send method transmits a DatagramPacket over the multicast connection.
 void setDataRate(long dataRate)
          Change the current data rate value.
 void setInterface(java.net.InetAddress ia)
          Set the interface which data will be transmitted on.
 void setSoTimeout(int timeout)
          Set the SO_TIMEOUT value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

getTransportProfile

public TransportProfile getTransportProfile()
Return a copy of the transport profile this socket is using.
Specified by:
getTransportProfile in interface RMPacketSocket
Returns:
a clone of the transport profile this socket is using.

getRMStatistics

public RMStatistics getRMStatistics()
                             throws UnsupportedException
Returns the latest snapshot of the maintained Transport statistics block.
Specified by:
getRMStatistics in interface RMPacketSocket
Returns:
a clone of the statistics block maintained by this socket.
Throws:
UnsupportedException - this method is not supported.

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 a 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.

send

public void send(java.net.DatagramPacket dp,
                 byte ttl)
          throws java.io.IOException
The send method transmits a DatagramPacket over the multicast connection. This method allows for setting the TTL on this transmission. If the desired TTL is different from the default set in the Transport Profile, this send method can be used. This does not alter the default ttl.
Parameters:
dp - the DatagramPacket to be sent.
ttl - optional time to live the the multicast packet.
Throws:
java.io.IOException - is raised if an error occurs sending the data.

receive

public java.net.DatagramPacket receive()
                                throws java.io.IOException
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.

abort

public void abort()
Abort the current connection. All packets in the send queue are lost.
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

getSoTimeout

public int getSoTimeout()
                 throws java.net.SocketException
Return the SO_TIMEOUT setting in milliseconds. A value of zero indicates an infinite timeout.
Returns:
the SO_TIMEOUT value.
Throws:
java.net.SocketException - if the multicast socket is invalid.

setSoTimeout

public void setSoTimeout(int timeout)
                  throws java.net.SocketException
Set the SO_TIMEOUT value. A non-zero value for this allows a call to receive to wait timeout milliseconds before returning with an InterruptedIOException. The socket is still valid.
Parameters:
timeout - the time in milliseconds to wait for data to be returned.
Throws:
java.net.SocketException - if the multicast socket is invalid.

getDataRate

public long getDataRate()
Returns:
the current value for the data rate in bytes/second

setDataRate

public void setDataRate(long dataRate)
Change the current data rate value. This changes the active value and the value in the current transport profile.
Parameters:
dataRate - the rate in bytes/second to transmit data.

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()


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