title: Client Server sockets java.net.SocketException: Software caused connection abort: recv failed
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/135919/java-net-socketexception-software-caused-connection-abort-recv-failed">java.net.SocketException: Software caused connection abort: recv failed</a>  </p>
  </blockquote>
  
  
  
  <p>I'm trying to write a client server pair where the connection is live all day and the client waits for the server to send a message.  The steps are:</p>
  
  <ol>
  <li>Server opens port and listens for connection</li>
  <li>Client connects in and waits for data</li>
  <li>Some time later (maybe hours) the server sends data to the client</li>
  <li>Client processes data and returns it to the server</li>
  <li>Repeat steps 3 and 4</li>
  </ol>
  
  <p>I can get steps 1-4 working, however if I try to repeat step 3 I get the error in the title.  </p>
  
  <p>This is my method on the client side:</p>
  
  <pre><code>private static void waitForInput(SSLSocket sslsocket) throws IOException {
          do {
              try {
                  ObjectInputStream ois = new ObjectInputStream(sslsocket.getInputStream());
                  ObjectOutputStream oos = new ObjectOutputStream(sslsocket.getOutputStream());
  
                  Object o = (Object) (ois.readObject());
                  // excluded code to process data     
  
                  oos.flush();
                  oos.writeObject(o);
                  oos.reset();
              }
              catch(ClassNotFoundException e){
                  System.err.println(e.getMessage());
              }
          } while ( true );
      }
  </code></pre>
  
  <p>The code fails on the 4th line, The first time around it blocks and waits until I get the next bit of data, but it doesn't work twice.  What am I doing wrong?</p>