Ejemplo n.º 1
0
  /** The "listen" thread that accepts a connection to the server */
  public void run() {

    Socket socket;

    // accept a connection
    try {
      System.out.println("Bank running, listening for connections on " + server.getInetAddress());
      socket = server.accept();
      System.out.println(
          Calendar.getInstance().getTime()
              + " - Accepted new connection from "
              + socket.getInetAddress());
      handleUser(socket);
      socket.close();
    } catch (IOException e) {
      System.out.println("Class Server died: " + e.getMessage());
      e.printStackTrace();
      return;
    }

    // create a new thread to accept the next connection
    newListener();
  }