X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Forg%2Fibex%2Fio%2FConnection.java;h=5c8c0fdc435f61897150089a0dbe9484417edaee;hb=3b2ea827949a6b21b360f43dc829e34650d9c203;hp=4233315989a408b038dc0265ad630b0f55a36e19;hpb=4ff117c6d6729fe941f77d99322c3515b467a5c4;p=org.ibex.io.git diff --git a/src/org/ibex/io/Connection.java b/src/org/ibex/io/Connection.java index 4233315..5c8c0fd 100644 --- a/src/org/ibex/io/Connection.java +++ b/src/org/ibex/io/Connection.java @@ -1,4 +1,7 @@ -// Copyright 2004 Adam Megacz, see the COPYING file for licensing [LGPL] +// Copyright 2000-2005 the Contributors, as shown in the revision logs. +// Licensed under the Apache Public Source License 2.0 ("the License"). +// You may not use this file except in compliance with the License. + package org.ibex.io; import java.net.*; @@ -10,12 +13,15 @@ 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 StreamException(e);} super.close(); } + 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 StreamException(e); }} - public void setTcpNoDelay(boolean delay) { try { s.setTcpNoDelay(delay);}catch(Exception e){throw new StreamException(e); }} + 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); }} }