X-Git-Url: http://git.megacz.com/?p=org.ibex.io.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fio%2FConnection.java;h=1ab0abe00646ae5da6d37c91d9a4cf1c135dfb5f;hp=c6d333f89317aada4f3943757283c29c257c7534;hb=5f7d531015927476bffd668f0a28960a60399093;hpb=e8cf0255da882a07bacc0fe7fd466f759cc8d3ef diff --git a/src/org/ibex/io/Connection.java b/src/org/ibex/io/Connection.java index c6d333f..1ab0abe 100644 --- a/src/org/ibex/io/Connection.java +++ b/src/org/ibex/io/Connection.java @@ -13,13 +13,19 @@ public class Connection extends Stream { private final Socket s; public final String vhost; public Connection(Socket s, String vhost) { super(s); this.vhost = vhost; this.s = s; } - public void close() { try{s.close();}catch(Exception e){throw new Stream.StreamException(e);} super.close(); } + protected Connection(InputStream i, OutputStream o) { super(i, o); vhost = null; s = null; } + public Socket getSocket() { return s; } + 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(); } } +