Exemplo n.º 1
0
  /** Starts the server, and waits for clients. */
  public Server() {
    instance = this;
    System.out.println(
        "== SERVER v" + Constants.NETCODE_VERSION + " == started at IP address: " + getLocalIP());
    clients = new LinkedList<ClientMachine>();

    try {
      beginListening(Constants.DEFAULT_PORT);
    } catch (BindException e) {
      Main.fatalError(
          "Couldn't bind to port "
              + Constants.DEFAULT_PORT
              + ". Perhaps a server is already running?\n\n"
              + e.getLocalizedMessage());
    } catch (SocketException ex) {
      ex.printStackTrace();
    }
  }