mil.navy.nps.bridge
Class AwtMulticastRelayClient

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byjava.applet.Applet
                  extended bymil.navy.nps.bridge.AwtMulticastRelayClient
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.ItemListener, java.awt.MenuContainer, java.io.Serializable

public class AwtMulticastRelayClient
extends java.applet.Applet
implements java.awt.event.ActionListener, java.awt.event.ItemListener

A quick applet that does local relay work for multicast. This is a bit better than a plain command line application. Lots of verbose and silly J++ comments included below.

Version:
1.0
Author:
Don McGregor http://www.npsnet.org/~mcgredo
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static boolean DEBUG
           
static java.lang.String DEFAULT_LOCAL_UNICAST
           
static java.lang.String DEFAULT_MCAST_ADDRESS
           
static java.lang.String DEFAULT_MCAST_PORT
           
static java.lang.String DEFAULT_SERVER
           
static java.lang.String DEFAULT_SERVER_PORT
           
protected static java.awt.TextField localUnicastPort
           
static boolean m_fStandAlone
           
static int MAX_PACKET_SIZE
           
protected static java.awt.TextField mcastRelayServer
           
protected static java.awt.TextField mcastRelayServerPort
           
protected static java.awt.Checkbox multicastCheckbox
           
protected static java.net.MulticastSocket multicastSocket
           
protected static java.awt.TextField packetCount
           
protected static java.awt.TextField port
           
(package private)  boolean receivedFromLocalhostOrLAN
           
(package private)  boolean receivedFromServer
           
protected  java.net.DatagramPacket replyPacket
           
protected static java.awt.TextField sendAddress
           
protected static boolean sending
           
static int SOCKET_TIMEOUT
           
protected static java.awt.CheckboxGroup socketTypeRadio
           
protected static java.awt.Button startButton
           
protected static java.awt.Button stopButton
           
static int TIME_TO_LIVE
           
protected static java.awt.Checkbox unicastCheckbox
           
protected static java.net.DatagramSocket unicastDatagramSocket
           
 
Fields inherited from class java.applet.Applet
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
AwtMulticastRelayClient()
          Main constructor, which lays out fields in the AWT.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent ae)
          ActionListener for the start and stop buttons.
static void debug(java.lang.String pDebugString)
          Debugging output.
 void destroy()
           
protected  void finalize()
           
 java.lang.String getAppletInfo()
           
 void init()
           
 void itemStateChanged(java.awt.event.ItemEvent e)
          itemStateChanged is the implementation of the interface ItemListener, which is used by checkboxes.
static void main(java.lang.String[] args)
           
 void paint(java.awt.Graphics g)
           
 void relayPackets()
          Does the dirty work of actually relaying the packets.
 java.lang.String respondToServer(java.net.DatagramSocket pSocket, java.net.DatagramPacket pPacket, java.net.InetAddress address, int port)
          check for hello packets from server and respond with "iAmHere" for each packet received.
 void start()
           
 void stop()
           
protected static void trace(java.lang.String pDiagnostic)
          Guaranteed debugging output.
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_SERVER

public static final java.lang.String DEFAULT_SERVER
See Also:
Constant Field Values

DEFAULT_SERVER_PORT

public static final java.lang.String DEFAULT_SERVER_PORT
See Also:
Constant Field Values

DEFAULT_MCAST_ADDRESS

public static final java.lang.String DEFAULT_MCAST_ADDRESS
See Also:
Constant Field Values

DEFAULT_MCAST_PORT

public static final java.lang.String DEFAULT_MCAST_PORT
See Also:
Constant Field Values

TIME_TO_LIVE

public static final int TIME_TO_LIVE
See Also:
Constant Field Values

DEFAULT_LOCAL_UNICAST

public static final java.lang.String DEFAULT_LOCAL_UNICAST
See Also:
Constant Field Values

MAX_PACKET_SIZE

public static final int MAX_PACKET_SIZE
See Also:
Constant Field Values

DEBUG

public static final boolean DEBUG
See Also:
Constant Field Values

SOCKET_TIMEOUT

public static final int SOCKET_TIMEOUT
See Also:
Constant Field Values

replyPacket

protected java.net.DatagramPacket replyPacket

receivedFromServer

boolean receivedFromServer

receivedFromLocalhostOrLAN

boolean receivedFromLocalhostOrLAN

m_fStandAlone

public static boolean m_fStandAlone

mcastRelayServer

protected static java.awt.TextField mcastRelayServer

mcastRelayServerPort

protected static java.awt.TextField mcastRelayServerPort

sendAddress

protected static java.awt.TextField sendAddress

port

protected static java.awt.TextField port

localUnicastPort

protected static java.awt.TextField localUnicastPort

packetCount

protected static java.awt.TextField packetCount

socketTypeRadio

protected static java.awt.CheckboxGroup socketTypeRadio

multicastCheckbox

protected static java.awt.Checkbox multicastCheckbox

unicastCheckbox

protected static java.awt.Checkbox unicastCheckbox

sending

protected static boolean sending

startButton

protected static java.awt.Button startButton

stopButton

protected static java.awt.Button stopButton

unicastDatagramSocket

protected static java.net.DatagramSocket unicastDatagramSocket

multicastSocket

protected static java.net.MulticastSocket multicastSocket
Constructor Detail

AwtMulticastRelayClient

public AwtMulticastRelayClient()
Main constructor, which lays out fields in the AWT.

Method Detail

debug

public static void debug(java.lang.String pDebugString)
Debugging output. Pass in a string, and it gets printed out on the console. You can pass in strings such as "foo " + bar.getName().


trace

protected static void trace(java.lang.String pDiagnostic)
Guaranteed debugging output. Pass in a string, and it gets printed out on the console. You can pass in strings such as "foo " + bar.getName().


main

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

getAppletInfo

public java.lang.String getAppletInfo()

init

public void init()

destroy

public void destroy()

paint

public void paint(java.awt.Graphics g)

start

public void start()

stop

public void stop()

respondToServer

public java.lang.String respondToServer(java.net.DatagramSocket pSocket,
                                        java.net.DatagramPacket pPacket,
                                        java.net.InetAddress address,
                                        int port)
check for hello packets from server and respond with "iAmHere" for each packet received.


relayPackets

public void relayPackets()
Does the dirty work of actually relaying the packets. Connects up to the server, reads the packets, and spits them back out again on this side.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent ae)
ActionListener for the start and stop buttons. This uses the AWT 1.1 event model, and implemens the ActionListener interface.

Specified by:
actionPerformed in interface java.awt.event.ActionListener

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
itemStateChanged is the implementation of the interface ItemListener, which is used by checkboxes. The checkboxes add us as a listener, and we get their events. This is based on the Java 1.1 event model.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener

finalize

protected void finalize()