private static void handleConnection(Socket socket){
  try (BufferedReader reader=new BufferedReader(new InputStreamReader(socket.getInputStream(),"UTF-8"))){
    int character;
    StringBuilder b=new StringBuilder();
    while ((character=reader.read()) != -1) {
      b.append((char)character);
    }
    LOGGER.info(String.format("Received instance message: %s [%s]",b.toString(),socket));
    if (listener != null) {
      listener.newInstance(b.toString());
    }
  }
 catch (  IOException ex) {
    LOGGER.warning("Error handling connection: " + ex);
  }
}

private static void handleConnection ( Socket socket ) { try ( BufferedReader reader = new BufferedReader ( new InputStreamReader ( socket . getInputStream ( ) , "UTF-8" ) ) ) { int character ; StringBuilder b = new StringBuilder ( ) ; while ( ( character = reader . read ( ) ) != - 1 ) { b . append ( ( char ) character ) ; } LOGGER . info ( String . format ( "Received instance message: %s [%s]" , b . toString ( ) , socket ) ) ; if ( listener != null ) { listener . newInstance ( b . toString ( ) ) ; } } catch ( IOException ex ) { LOGGER . warning ( "Error handling connection: " + ex ) ; } }
handles an incoming connection from listening to the registered port . reads all received text and notifies the listener if there is one .
