submission.Demo
Class UDPEchoClient

java.lang.Object
  extended byjava.lang.Thread
      extended bysimnet.Application
          extended bysubmission.Demo.EchoClient
              extended bysubmission.Demo.UDPEchoClient
All Implemented Interfaces:
Pluggable, PlugoutListener, java.lang.Runnable, SimnetWindowListener

public class UDPEchoClient
extends EchoClient
implements Pluggable

An example of an EchoClient implemented with UDP.


Field Summary
protected  boolean keep_going
           
protected  DatagramSocket sock
           
 
Fields inherited from class submission.Demo.EchoClient
defaultPort
 
Fields inherited from class simnet.Application
appid, appstart, node, NODE_ID, pid, random, sim
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
UDPEchoClient()
           
 
Method Summary
 void customInit()
          Create a new datagram socket and bind it to any local port.
 void echo(java.lang.Integer host, java.lang.Integer port, java.lang.String msg)
           
 void echo(java.lang.Integer host, java.lang.String msg)
           
 void echo(int host, int port, java.lang.String msg)
           
 void echo(int host, java.lang.String msg)
           
 void echo(java.lang.String host, java.lang.Integer port, java.lang.String msg)
           
 void echo(java.lang.String host, java.lang.String msg)
          Send a message over the connection
 boolean prePlugout(java.lang.Object replacement)
          Tell our thread we are done, and close the socket if we are not being replaced.
 void run()
          Wait for messages to be received, and print them out.
 void status()
          Print a status of connection
 
Methods inherited from class simnet.Application
closeWindow, finalize, getTitleString, initialize, plugoutNotification, printout, printout, processWindowCommand, rawOut, window
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sock

protected DatagramSocket sock

keep_going

protected transient boolean keep_going
Constructor Detail

UDPEchoClient

public UDPEchoClient()
Method Detail

customInit

public void customInit()
Create a new datagram socket and bind it to any local port.

Overrides:
customInit in class Application

echo

public void echo(java.lang.String host,
                 java.lang.String msg)
Send a message over the connection


echo

public void echo(java.lang.Integer host,
                 java.lang.String msg)

echo

public void echo(int host,
                 int port,
                 java.lang.String msg)

echo

public void echo(java.lang.String host,
                 java.lang.Integer port,
                 java.lang.String msg)

echo

public void echo(java.lang.Integer host,
                 java.lang.Integer port,
                 java.lang.String msg)

echo

public void echo(int host,
                 java.lang.String msg)

run

public void run()
Wait for messages to be received, and print them out.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class Application

status

public void status()
Print a status of connection


prePlugout

public boolean prePlugout(java.lang.Object replacement)
Tell our thread we are done, and close the socket if we are not being replaced.

Specified by:
prePlugout in interface Pluggable
Returns:
if this object can now be removed (was the operation sucessful)