improve exception handling
[org.ibex.io.git] / src / org / ibex / io / Connection.java
index 5c8c0fd..1ab0abe 100644 (file)
@@ -15,13 +15,17 @@ public class Connection extends Stream {
     public Connection(Socket s, String vhost) { super(s); this.vhost = vhost; this.s = s; }
     protected Connection(InputStream i, OutputStream o) { super(i, o); vhost = null; s = null; }
     public Socket getSocket() { return s; }
-    public void close()                       { try{if (s!=null) s.close();}catch(Exception e){throw new Stream.StreamException(e);} super.close(); }
+
     public int getLocalPort()                 { return s.getLocalPort(); }
     public InetAddress getLocalAddress()      { return ((InetSocketAddress)s.getLocalSocketAddress()).getAddress(); }
     public int getRemotePort()                { return s.getPort(); }
     public InetAddress getRemoteAddress()     { return ((InetSocketAddress)s.getRemoteSocketAddress()).getAddress(); }
     public String getRemoteHostname()         { return getRemoteAddress().getHostName(); }
     public String getVirtualHost()            { return vhost; }
-    public void setTimeout(int ms)            { try { s.setSoTimeout(ms); } catch (Exception e){throw new Stream.StreamException(e); }}
-    public void setTcpNoDelay(boolean delay)  { try { s.setTcpNoDelay(delay);}catch(Exception e){throw new Stream.StreamException(e); }}
+    public void setTimeout(int ms)            { try { s.setSoTimeout(ms);     } catch(IOException e) { ioe(e); } }
+    public void setTcpNoDelay(boolean delay)  { try { s.setTcpNoDelay(delay); } catch(IOException e) { ioe(e); } }
+
+    /** never throws an exception */
+    public void close()                       { try{if (s!=null) s.close();}catch(Exception e){/*ignore*/} super.close(); }
 }
+