title: If a socket accept causes a exception, how can I find out the reason?
body: <p>I'm creating a function that will do a socket accept and return 3 vales
  0=really bad error happen exit thread
  1=ok talk to the connection
  =something happen, do another accept (time out).</p>
  
  <p>I see the IOException  has a GetCause meths that returns a throwable object.
  this throwable object has a get cause method that returns a throwable, which has a getcuase method returning a throwable, seems like this would go on forever, keep getting another throwable object.</p>
  
  <p>How can I get the reason the exception ant off?????
  I could use get reason and a bunch of string compares, but this does not seem to reliable.
  Ted</p>
  
  <pre><code>int GetClient()
  {
      try {
          server.setSoTimeout(5*1);  
          connection=server.accept();
      }
      catch(IOException ec)
      {
          System.out.println(Thread.currentThread()+":"+ec.getMessage()); 
  
  
          return 2; // for time out or something where we can try again
          // return a zero saying we must stop erra o bad
  
      }   
      return 1;
  }
  </code></pre>