@Override
  public void run() {
    // Wait for clients to connect.
    // When a client has connected, create a new ClientConnection
    Socket clientSock = null;
    channel.startServer();

    while (true) {
      clientSock = channel.accept();
      System.out.println("A new client has connected");

      if (clientSock != null) {
        ClientConnection clientConn = new ClientConnection(clientSock, this, nextClientID);

        nextClientID++;

        Thread thread = new Thread(clientConn);
        thread.start();
        clientSock = null;
      }

      System.out.println(
          "Client has been served by ClientHandler. " + "Now looking for new connections");
    }
  }
예제 #2
0
 /** {@inheritDoc} */
 @Override
 public void expire() {
   try {
     eventDispatcher.shutdown();
   } finally {
     super.expire();
   }
 }