simnet
Class TCPPingPongClient

java.lang.Object
  extended byjava.lang.Thread
      extended bysimnet.Application
          extended bysimnet.TCPPingPongClient
All Implemented Interfaces:
Pluggable, PlugoutListener, java.lang.Runnable, SimnetWindowListener

public class TCPPingPongClient
extends Application
implements Pluggable


Nested Class Summary
private  class TCPPingPongClient.EchoThread
           
 
Field Summary
protected  int defaultPort
           
protected  boolean first
           
protected  Socket sock
           
 
Fields inherited from class simnet.Application
appid, appstart, frame, initialized, node, NODE_ID, pid, random, sim, win
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
TCPPingPongClient()
           
 
Method Summary
 void close()
          Close the connection if it is currently open.
 void connect(int host)
          Connect to the specified host on the default port.
 void connect(java.lang.Integer host)
           
 void connect(java.lang.Integer host, java.lang.Integer port)
           
 void connect(int host, int port)
           
 void connect(java.lang.String host)
          Connect to an echo server.
 void connect(java.lang.String host, java.lang.Integer port)
           
 void customInit()
          This is where an application can do any application-specific initializeation it requires.
 void echo(java.lang.Integer times, java.lang.Integer randRange)
          Send a message across the connection.
 void echo(int times, int randRange)
           
 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 Socket sock

first

protected boolean first

defaultPort

protected int defaultPort
Constructor Detail

TCPPingPongClient

public TCPPingPongClient()
Method Detail

customInit

public void customInit()
Description copied from class: Application
This is where an application can do any application-specific initializeation it requires.

Overrides:
customInit in class Application

connect

public void connect(java.lang.String host)
Connect to an echo server.


connect

public void connect(java.lang.Integer host)

connect

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

connect

public void connect(java.lang.Integer host,
                    java.lang.Integer port)

connect

public void connect(int host,
                    int port)

connect

public void connect(int host)
Connect to the specified host on the default port.


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

close

public void close()
Close the connection if it is currently open.


echo

public void echo(java.lang.Integer times,
                 java.lang.Integer randRange)
Send a message across the connection.


echo

public void echo(int times,
                 int randRange)

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)