examples.example3_one_client_OO_library
Class ClientRunner

java.lang.Object
  extended by examples.example3_one_client_OO_library.ClientRunner
All Implemented Interfaces:
Runnable

public class ClientRunner
extends Object
implements Runnable

 A simple example of communication between this Client and the Server.
 
 It behaves as follows:
 
 Initiate the protocol by sending a random number to the Server. Then:
 
 Repeatedly, until the Server sends STOP or the user says to stop:
   -- Get a number from the Server.
   -- Add a random number between 0 and 10 to it.
   -- After pausing 0 to 5 seconds, send the revised number to the Server.
   
 The Server can send whatever number it wishes at each iteration;
 in fact, the particular Server in this program takes the number
 that the Client sends it, asks the user for another number,
 and sends the sum of the two numbers back to this Client.
 
 If the user says to stop, the Client sends a STOP message to the Server
 so that the Server will stop too.
 

Author:
David Mutchler, based on the Java Tutorials on networking. May, 2009.

Constructor Summary
ClientRunner(Client client)
          Starts a Thread in which the given Client does whatever it is supposed to do.
 
Method Summary
 void run()
           A simple example of communication between this Client and the Server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClientRunner

public ClientRunner(Client client)
Starts a Thread in which the given Client does whatever it is supposed to do.

Parameters:
client - Client to run.
Method Detail

run

public void run()
 A simple example of communication between this Client and the Server.
 
 It behaves as follows:
 
 Initiate the protocol by sending a random number to the Server. Then:
 
 Repeatedly, until the Server sends STOP or the user says to stop:
   -- Get a number from the Server.
   -- Add a random number between 0 and 10 to it.
   -- After pausing 0 to 5 seconds, send the revised number to the Server.
   
 The Server can send whatever number it wishes at each iteration;
 in fact, the particular Server in this program takes the number
 that the Client sends it, asks the user for another number,
 and sends the sum of the two numbers back to this Client.
 
 If the user says to stop, the Client sends a STOP message to the Server
 so that the Server will stop too.
 

Specified by:
run in interface Runnable