title: Java Networking Server, protocol and client
body: <p>I have this multi server thread, so whenever the 'X' button is click on the top right hand corner, i want to display the message "closing the socket" on the server side.</p>
  
  <pre><code>public void run
  {
  
    try
    {
      // .....
       String inputLine, outputLine;
      Protocol p = new Protocol();
      outputLine = p.processInput(null, p);
      out.println(outputLine);
  
     while ((inputLine = in.readLine()) != null) {
      outputLine = p.processInput(inputLine,p);
      out.println(outputLine);
      if (outputLine.equals("Bye"))
              {
                  System.out.print("Closing socket.");
                  break;
              }
      }
  
  
      out.close();
      in.close();
      socket.close();
   catch (IOException e)
   {
      // .....
    }
  
  }
  
  public String processInput(String theInput, Protocol p) 
   {
       theOutput = null;
  
  
       frame = new JFrame ("Find The Word!");
        frame.addWindowListener( new WindowAdapter()
      {
          public void windowClosing(WindowEvent e)
          {
                theOutput = "Bye";
          }
      });
  
      frame.add(p);
      frame.pack();
  
      frame.setVisible(true);
  
  
  
  
  
      return theOutput;
  } 
  </code></pre>
  
  <p>But it doesn't work, and i have to manually end the process for the server side. I assume that it got stuck at the while loop, but i couldn't figure out whats wrong with it.</p>