import java.net.*; import java.io.*; import java.util.*; class Server implements Runnable { private static final int DEFAULT_PORT = 8667; private ServerSocket mainSock = null; private static Vector conVec = new Vector(7, 2); // connection vector public int this_port = DEFAULT_PORT; Thread runner; /** * constructor */ public Server() { try { mainSock = new ServerSocket(this_port); } catch(Exception e) { System.err.println("Can't create system socket, system exits."); System.exit(1); } } /** * waits for a connection then spawns a ServerManager to deal with it */ public void run() { // continuously listen the socket while (true) { try { Socket this_connection = mainSock.accept(); ServerManager manager = new ServerManager(this_connection, this); manager.start(); conVec.addElement(manager); //clean up the vector if needed for (int i=0; i