examples.example3_one_client_OO_library
Class ServerRunner

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

public class ServerRunner
extends Object
implements Runnable

 A simple example of communication between this Server and the Client.
 
 It behaves as follows:
 
 Repeatedly, until the Client sends STOP or the user says to stop:
   -- Get a number from the Client.
   -- Display the number from the Client, and get a number from the user.
   -- Add these numbers and send the total to the Client.
   
 The Client can send whatever number it wishes at each iteration;
 in fact, the particular Client in this program takes the number
 that the Server sends it, chooses a random number between 0 and 10,
 and sends the sum back to this Server.
 
 If the user says to stop, the Server sends a STOP message to the Client
 so that the Client will stop too.
 

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

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

Constructor Detail

ServerRunner

public ServerRunner(Server server)
Starts a Thread in which the given Server does whatever it is supposed to do.

Parameters:
server - Server to run.
Method Detail

run

public void run()
 A simple example of communication between this Server and the Client.
 
 It behaves as follows:
 
 Repeatedly, until the Client sends STOP or the user says to stop:
   -- Get a number from the Client.
   -- Display the number from the Client, and get a number from the user.
   -- Add these numbers and send the total to the Client.
   
 The Client can send whatever number it wishes at each iteration;
 in fact, the particular Client in this program takes the number
 that the Server sends it, chooses a random number between 0 and 10,
 and sends the sum back to this Server.
 
 If the user says to stop, the Server sends a STOP message to the Client
 so that the Client will stop too.
 

Specified by:
run in interface Runnable