public static void main(String[] args) {
    int newport = 0;
    String log = "";

    if (args.length > 0) {
      args[0].trim();

      try {
        newport = Integer.parseInt(args[0]);
      } catch (NumberFormatException e) {
        if (!args[0].equalsIgnoreCase("-h")) {
          System.out.println("server: Invalid argument");
        } else {
          System.out.println("Syntax: java Server [port-number]");
        }

        System.exit(0);
      }
    } else {
      newport = defaultPort; // falls kein Port angegeben wurde
    }

    if (newport < 1024) { // teste, ob Portnummer gueltig ist
      System.out.println("server: Invalid port number! Using default port " + defaultPort);
      newport = defaultPort;
    }

    try {
      Server serv = new Server(newport);

      while (true) {
        serv.connection = serv.servSocket.accept(); // blockiert, bis neuer
        // Client sich anmeldet
        serv.connection.setSoTimeout(60000);
        serv.in = new BufferedReader(new InputStreamReader(serv.connection.getInputStream()));
        String msg = serv.receive();
        serv.addPlayer(msg); // hier werden die Spieldaten erwartet
        // (Spielname, min/maxPlayer)
        log = "server: Accepted new connection to client on port " + serv.connection.getPort() + "\n";
        System.out.print(log);
        serv.log(log, newport);
        log = "server:received data from new player: " + msg + "\n";
        System.out.print(log);
        serv.log(log, newport);
      }
    } catch (InterruptedIOException e) {
      System.out.println("server: client not responding");
    } catch (IOException e) {
      System.out.println("server: error connecting to client");
    }
  }