inria.net
Class MulticastSession

java.lang.Object
  |
  +--inria.net.MulticastSession
All Implemented Interfaces:
java.lang.Runnable

public abstract class MulticastSession
extends java.lang.Object
implements java.lang.Runnable

an abstract class for managing a multicast/unicast session over DatagramSocket.


Field Summary
protected  int bytes
           
protected  java.net.InetAddress inetAddr
           
protected  int MaxPacketSize
           
protected  int packets
           
protected  int port
           
protected  java.net.DatagramSocket sock_in
           
protected  java.net.DatagramSocket sock_out
           
protected  java.lang.Thread thread
           
protected  int ttl
           
 
Constructor Summary
protected MulticastSession()
          creates a MulticastSession object.
 
Method Summary
 int bytes()
          returns the total number of bytes received.
 int getTTL()
          gets the TTL value.
protected  void initialize(java.net.InetAddress addr, int port)
          creates MulticastSocket or DatagramSocket according to the class of the given IP address.
protected  void initialize(java.lang.String addr, int port)
          creates MulticastSocket or DatagramSocket according to the class of the given IP address.
static boolean isMulticast(java.net.InetAddress addr)
          returns true if the address is in class D.
 int packets()
          returns the total number of packets received.
protected abstract  boolean parse(byte[] buff, int datalen, java.net.InetAddress addr)
          parses a received data packet.
 void run()
          starts to receive packets from the session.
 void send(byte[] buff, int len)
          sends data to the session using the session TTL.
 void send(byte[] buf, int len, int ttl)
          sends data to the session using the provided TTL.
 void setTTL(int t)
          sets the TTL for a multicast session.
 void start()
          starts the session.
 void stop()
          stops the session.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MaxPacketSize

protected int MaxPacketSize

port

protected int port

ttl

protected int ttl

inetAddr

protected java.net.InetAddress inetAddr

sock_in

protected java.net.DatagramSocket sock_in

sock_out

protected java.net.DatagramSocket sock_out

packets

protected int packets

bytes

protected int bytes

thread

protected java.lang.Thread thread
Constructor Detail

MulticastSession

protected MulticastSession()
creates a MulticastSession object.
Method Detail

start

public void start()
starts the session.

stop

public void stop()
stops the session.

initialize

protected void initialize(java.net.InetAddress addr,
                          int port)
                   throws java.io.IOException
creates MulticastSocket or DatagramSocket according to the class of the given IP address.
Parameters:
addr - the destination address.
port - the port to use.
Throws:
java.io.IOException - is raised if there is an error in creating socket.

initialize

protected void initialize(java.lang.String addr,
                          int port)
                   throws java.io.IOException,
                          java.net.UnknownHostException
creates MulticastSocket or DatagramSocket according to the class of the given IP address.
Parameters:
addr - the destination address.
port - the port to use.
Throws:
java.net.UnknownHostException - is raised if bad address.
java.io.IOException - is raised if there is an error in creating socket.

setTTL

public void setTTL(int t)
sets the TTL for a multicast session.
Parameters:
t - TTL.

getTTL

public int getTTL()
gets the TTL value.

send

public void send(byte[] buff,
                 int len)
sends data to the session using the session TTL.
Parameters:
buff - the data buffer.
len - the data length in the buffer.

send

public void send(byte[] buf,
                 int len,
                 int ttl)
sends data to the session using the provided TTL.
Parameters:
buff - the data buffer.
len - the data length in the buffer.
ttl - the ttl value to use.

parse

protected abstract boolean parse(byte[] buff,
                                 int datalen,
                                 java.net.InetAddress addr)
parses a received data packet. To be implemented by subclasses.
Parameters:
buff - the data buffer.
datalen - the data length in the buffer.
addr - the source network address.

run

public void run()
starts to receive packets from the session.
Specified by:
run in interface java.lang.Runnable

isMulticast

public static boolean isMulticast(java.net.InetAddress addr)
returns true if the address is in class D.
Parameters:
addr - address to check.

packets

public int packets()
returns the total number of packets received.

bytes

public int bytes()
returns the total number of bytes received.


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