public void run(){
  log.info("IdentServer running on port " + serverSocket.getLocalPort());
  while (!serverSocket.isClosed()) {
    Socket socket=null;
    try {
      socket=serverSocket.accept();
      BufferedReader reader=new BufferedReader(new InputStreamReader(socket.getInputStream(),encoding));
      OutputStreamWriter writer=new OutputStreamWriter(socket.getOutputStream(),encoding);
      InetSocketAddress remoteAddress=(InetSocketAddress)socket.getRemoteSocketAddress();
      String line=reader.readLine();
      String response=handleNextConnection(remoteAddress,line);
      if (response != null) {
        writer.write(response);
        writer.flush();
      }
    }
 catch (    Exception e) {
      if (serverSocket.isClosed()) {
        log.debug("Server socket closed, exiting connection loop");
        return;
      }
 else       throw new RuntimeException("Exception encountered when opening user socket",e);
    }
 finally {
      try {
        if (socket != null)         socket.close();
      }
 catch (      IOException e) {
        throw new RuntimeException("Exception encountered when closing user socket",e);
      }
    }
  }
  if (!serverSocket.isClosed())   try {
    close();
  }
 catch (  IOException e) {
    log.error("Cannot close IdentServer socket",e);
  }
}

public void run ( ) { log . info ( "IdentServer running on port " + serverSocket . getLocalPort ( ) ) ; while ( ! serverSocket . isClosed ( ) ) { Socket socket = null ; try { socket = serverSocket . accept ( ) ; BufferedReader reader = new BufferedReader ( new InputStreamReader ( socket . getInputStream ( ) , encoding ) ) ; OutputStreamWriter writer = new OutputStreamWriter ( socket . getOutputStream ( ) , encoding ) ; InetSocketAddress remoteAddress = ( InetSocketAddress ) socket . getRemoteSocketAddress ( ) ; String line = reader . readLine ( ) ; String response = handleNextConnection ( remoteAddress , line ) ; if ( response != null ) { writer . write ( response ) ; writer . flush ( ) ; } } catch ( Exception e ) { if ( serverSocket . isClosed ( ) ) { log . debug ( "Server socket closed, exiting connection loop" ) ; return ; } else throw new RuntimeException ( "Exception encountered when opening user socket" , e ) ; } finally { try { if ( socket != null ) socket . close ( ) ; } catch ( IOException e ) { throw new RuntimeException ( "Exception encountered when closing user socket" , e ) ; } } } if ( ! serverSocket . isClosed ( ) ) try { close ( ) ; } catch ( IOException e ) { log . error ( "Cannot close IdentServer socket" , e ) ; } }
waits for a client to connect to the ident server before making an appropriate response .
