FileDocCategorySizeDatePackage
RunnableSolverServer.javaAPI DocExample1574Sat Jan 31 22:41:52 GMT 1998dcj.examples

RunnableSolverServer

public class RunnableSolverServer extends SimpleServer
Source code from "Java Distributed Computing", by Jim Farley. Class: RunnableSolverServer Example: 4-2 Description: A SimpleServer that starts an independent thread to service each client request.

Fields Summary
Constructors Summary
public RunnableSolverServer()

 super(3000); 
public RunnableSolverServer(int port)

 super(port); 
Methods Summary
public static voidmain(java.lang.String[] argv)

    int port = 3000;
    if (argv.length > 0) {
      try {
        port = Integer.parseInt(argv[0]);
      }
      catch (NumberFormatException e) {
        System.err.println("Bad port number given.");
        System.err.println("   Using default port.");
      }
    }

    RunnableSolverServer server = new RunnableSolverServer(port);
    System.out.println("RunnableSolverServer running on port " + port + "...");
    server.listen();
  
public voidserviceClient(java.net.Socket clientConn)

    InputStream inStream = null;
    OutputStream outStream = null;

    try {
      inStream = clientConn.getInputStream();
      outStream = clientConn.getOutputStream();
    }
    catch (IOException e) {
      System.out.println("RunnableSolverServer: Error getting I/O streams.");
      System.exit(1);
    }

    RunnableSolver s = new RunnableSolver(inStream, outStream);
    Thread t = new Thread(s);
    t.start();