mil.navy.nps.bridge
Class MulticastTunnelServer

java.lang.Object
  extended bymil.navy.nps.bridge.MulticastTunnelServer

public class MulticastTunnelServer
extends java.lang.Object


Nested Class Summary
(package private)  class MulticastTunnelServer.Reaper
          An inner class that implements the Runnable interface.
 
Field Summary
(package private)  java.util.HashSet channels
           
(package private)  java.util.HashSet clients
           
(package private)  java.net.DatagramSocket serverSocket
           
 
Method Summary
protected  void connect(java.lang.String pConnectCommand)
          Handles connect commands.
protected  void disconnect(java.net.InetAddress pClientAddress, int pClientPort)
          Removes the client from all channels.
static MulticastTunnelServer getInstance(int pPort)
          implementation of the singleton pattern.
protected  void keepAlive(java.net.InetAddress pClientAddress, int pPort)
          Handles the keepAlive server command.
static void main(java.lang.String[] args)
          Main entry point.
 void removeChannel(Channel pChannel)
          removeChannel.
 void run()
          Implementation of the Runnable interface.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clients

java.util.HashSet clients

channels

java.util.HashSet channels

serverSocket

java.net.DatagramSocket serverSocket
Method Detail

getInstance

public static MulticastTunnelServer getInstance(int pPort)
implementation of the singleton pattern. Uses a private constructor to build a single instance of MulticastTunnelServer.


run

public void run()
Implementation of the Runnable interface. This listens for commands and forwards them to the appropriate handler. It also kicks of a "reaper" thread that handles the keepAlive timeout housekeeping.


connect

protected void connect(java.lang.String pConnectCommand)
Handles connect commands. Connect commands are of the form connect clientMachineAddress clientMachinePort multicastAddress multicastPort We parse this out via a tokenizer, which just takes the items one by one. Note that the command string should be followed by a space, or the parser will be unable to tell when the command quits and when gibberish at the end of the packet begins.


disconnect

protected void disconnect(java.net.InetAddress pClientAddress,
                          int pClientPort)
Removes the client from all channels.


removeChannel

public void removeChannel(Channel pChannel)
removeChannel. This should not be called unless you're certain that all clients have been removed first.


keepAlive

protected void keepAlive(java.net.InetAddress pClientAddress,
                         int pPort)
Handles the keepAlive server command. Updates the timestamp on the client so the reaper process doesn't close it down.


main

public static void main(java.lang.String[] args)
Main entry point.