title: Handling java.net.SocketException
body: <p>I have a program which sometimes encounters the errorjava.net.SocketException. Is there a way I can have the client program execute some code if (and only if) it encounters this error in order to "deal with" the error? The full error is </p>
  
  <pre><code>java.net.SocketException: Software caused connection abort: socket write error
  </code></pre>
  
  <p>Here's a summary of what I have now. </p>
  
  <pre><code>public void run()  {
      try {
          //some code that causes the SocketException 
      }
  
      catch (SocketException e) {
      System.out.println("I recognize the SocketException");
      }
  }
  </code></pre>
  
  <p>However despite the error it still won't print the line.</p>
  
  <p>Here is the full error</p>
  
  <pre><code>java.net.SocketException: Software caused connection abort: socket write error
      at java.net.SocketOutputStream.socketWrite0(Native Method)
      at java.net.SocketOutputStream.socketWrite(Unknown Source)
      at java.net.SocketOutputStream.write(Unknown Source)
      at java.io.ObjectOutputStream$BlockDataOutputStream.drain(Unknown Source)
      at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(Unknown Source)  
      at java.io.ObjectOutputStream.writeNonProxyDesc(Unknown Source)
      at java.io.ObjectOutputStream.writeClassDesc(Unknown Source)
      at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
      at java.io.ObjectOutputStream.writeObject0(Unknown Source)
      at java.io.ObjectOutputStream.writeFatalException(Unknown Source)
      at java.io.ObjectOutputStream.writeObject(Unknown Source)
      at (...).java:61)
      at (...).java:164)
  </code></pre>