FileDocCategorySizeDatePackage
clientTester.javaAPI DocExample1900Thu Apr 03 15:24:10 BST 1997None

clientTester

public class clientTester extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)


    int thePort;
    ServerSocket ss;
    Socket theConnection;
    
    try {
      thePort = Integer.parseInt(args[0]);
    }  
    catch (Exception e) {
      thePort = 0;
    }
    
    try {
      ss = new ServerSocket(thePort);
      System.out.println("Listening for connections on port " + ss.getLocalPort());

      while (true) {
        theConnection = ss.accept();
        System.out.println("Connection established with " + theConnection);
        InputThread it = new InputThread(theConnection.getInputStream());
        it.start();
        OutputThread ot = new OutputThread(theConnection.getOutputStream(), it);
        ot.start();
        // need to wait for ot and it to finish 
        try {
          ot.join();
          it.join();
        }
        catch (InterruptedException e) {
        } 
      }
    }
    catch (IOException e) {
    
    }