if (port == 0) port = DEFAULT_PORT; this.port = port; try { listen_socket = new ServerSocket(port); } catch (IOException e) { fail(e, "Exception creating server socket"); } System.out.println("Server: listening on port " + port); this.start();
// Exit with an error message, when an exception occurs. System.err.println(msg + ": " + e); System.exit(1);
int port = 0; if (args.length == 1) { try { port = Integer.parseInt(args[0]); } catch (NumberFormatException e) { port = 0; } } new Server(port);
try { while(true) { Socket client_socket = listen_socket.accept(); Connection c = new Connection(client_socket); } } catch (IOException e) { fail(e, "Exception while listening for connections"); }