title: closing client let the server crash
body: <p>I've a simple client and server on android. Everything works fine except when I close the client app then the server stops working the app closes.</p>
  
  <p>I think it's about not closing the socket. But when I close the socket in the client the server still stops working. </p>
  
  <p>I'm running a thread on the server. This is my server code:</p>
  
  <pre><code>this.serverThread = new Thread(new ServerThread());
          this.serverThread.start();
  
      }
  
  
      @Override
      protected void onStop() {
          super.onStop();
          try {
              serverSocket.close();
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  
      class ServerThread implements Runnable {
  
          public void run() {
              Socket socket = null;
              try {
                  serverSocket = new ServerSocket(SERVERPORT);
              } catch (IOException e) {
                  e.printStackTrace();
              }
              while (!Thread.currentThread().isInterrupted()) {
  
                  try {
  
                      socket = serverSocket.accept();
  
                      CommunicationThread commThread = new CommunicationThread(socket);
                      new Thread(commThread).start();
  
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
          }
      }
  
      class CommunicationThread implements Runnable {
  
          private Socket clientSocket;
  
          private BufferedReader input;
  
          public CommunicationThread(Socket clientSocket) {
  
              this.clientSocket = clientSocket;
  
              try {
  
                  this.input = new BufferedReader(new InputStreamReader(this.clientSocket.getInputStream()));
  
              } catch (IOException e) {
                  e.printStackTrace();
              }
          }
  
          public void run() {
  
  
              while (!Thread.currentThread().isInterrupted()) {
  
                  try {
  
                      String read = input.readLine();
  
                      updateConversationHandler.post(new updateUIThread(read));
  
                  } catch (IOException e) {
                      e.printStackTrace();
                  }
              }
          }
  
      }
  
      class updateUIThread implements Runnable {
          private String msg;
          private boolean feedback = false;
  
          public updateUIThread(String str) {
              msg = str;
          }
  
          @Override
          public void run() {
              parseCommand();
              if(feedback)
              {
                  textFeedback.setText(msg);
                  feedback = false;
              }
              else
              {
                  textTv.setText(msg);
              }
          }
  </code></pre>