Code example for ServerSocket

Methods: getInetAddress

0
  /** 
   * Sets up the TCP/IP server socket. 
   */ 
  private void setupServer() throws IOException { 
    Log.d(LOG_TAG, "Setting up server...");
    socket = new ServerSocket(SERVER_PORT);
    Log.i(LOG_TAG, "Listening on " + socket.getInetAddress().getHostAddress());
    connectionThread = new Thread(new Runnable() {
      public void run() { 
        try { 
          while ( !isDead ) {
            Socket client = socket.accept();
            clients.push(client);
          } 
        } catch ( Exception ex ) {
          Log.e(LOG_TAG, "Error accepting connection: " + ex.getMessage());
        } 
      } 
    }); 
    connectionThread.start();