title: Duplicate reception of message when reconnecting a socket
body: <p>I'm having problems with a simple java socket client: the connection is established properly and both server and client receive and send data. When the client loses connectivity for a couple of seconds, the socket is finished and reestablished. This is  done ok but in that moment, the last received message by the client (previous to the reconnection) is received again (2 receptions of the same message) with no reason. </p>
  
  <p><strong>My code is:</strong></p>
  
  <p><em>To start the socket:</em></p>
  
  <pre><code>Socket sock = new Socket();
  sock.bind(null);
  InetSocketAddress isa = new InetSocketAddress(serverIPAddress,serverPort);
  sock.connect(isa, conectionTimeOut);
  sock.setKeepAlive(true);
  
  InputStreamReader isR = new InputStreamReader(sock.getInputStream(), "UTF8");
  reader = new BufferedReader(isR);
  
  out = new BufferedWriter(new OutputStreamWriter(
      sock.getOutputStream(), "UTF8"));
  </code></pre>
  
  <p><em>Reading data:</em></p>
  
  <pre><code>public class IncomingReader implements Runnable {
      String message = "";
  
      @Override
      public void run() {
          Thread thisThread = Thread.currentThread();
          while (readerThread == thisThread) {
              try {
                  while ((message = reader.readLine()) != null) {
                      manageServerMessage(message);
                  }
              } catch (IOException e) {
                  Log.d(General.TAG, e.getMessage()+" "+e.getCause());
              }
          }
  </code></pre>
  
  <p><em>When the connection is lost:</em></p>
  
  <pre><code>public void stopSocket() {
      readerThread = null;
      try{
          if (reader != null){
              reader.close();
              reader=null;
          }
      } catch (IOException e) {
          Log.d(General.TAG, e.getMessage()+"    "+e.getCause());
      }
      try{
          if (out != null)
              out.close();
      } catch (IOException e) {
          Log.d(General.TAG, e.getMessage()+" "+e.getCause());
      }
      try{
          if (sock != null){
              sock.close();
              sock=null;
          }
      } catch (IOException e) {
          Log.d(General.TAG, e.getMessage()+"    "+e.getCause());
          sock=null;
      }
      readerThread = null;
  }
  </code></pre>