Esempio n. 1
0
  public static void main(String[] args) throws IOException {
    Server server = new Server(PORT);
    Socket client = server.listen();

    ChatDialog chat = new ChatDialog(client);
    chat.pack();
    SwingUtilities.invokeLater(() -> chat.setVisible(true));
    chat.start();
    System.exit(0);
  }
Esempio n. 2
0
  /**
   * Constructor, makes a new server listening on specified port.
   *
   * @param port The port to listen on.
   */
  public Server(int port) {
    clientcounter = 0;
    shutdown = false;
    try {
      serversock = new ServerSocket(port);
    } catch (IOException e) {
      System.out.println("Could not create server socket.");
      return;
    }
    /* Server socket open, make a vector to store active threads. */
    serverthreads = new Vector<ServerThread>(0, 1);

    /* Output connection info for the server */
    System.out.println(
        "Server IP address: " + serversock.getInetAddress().getHostAddress() + ",  port " + port);

    /* listen on the socket for connections. */
    listen();
  }
Esempio n. 3
0
  public static void main(String[] args) {
    parseCommandLine(args);

    DebugStream debug;
    try {
      debug = new DebugStream("server.debug");
    } catch (IOException e) {
      System.err.println("Couldn't open debug log file. Exiting.");
      e.printStackTrace();
      return;
    }

    Config config = new Config(debug);
    // config.read();
    // readAbilities();

    // initSignals();

    // initGame();

    Server server = new Server(config, debug);
    server.listen();
  }
Esempio n. 4
0
 @Override
 public CompletableFuture<Void> listen(Address address, Consumer<Connection> listener) {
   Assert.notNull(address, "address");
   Assert.notNull(listener, "listener");
   return local.listen(address, listener).thenCompose(v -> remote.listen(address, listener));
 }