1 // Copyright 2004 Adam Megacz, see the COPYING file for licensing [LGPL]
6 import org.ibex.util.*;
8 /** a stream backed by a socket */
9 public class Connection extends Stream {
10 private final Socket s;
11 public final String vhost;
12 public Connection(Socket s, String vhost) { super(s); this.vhost = vhost; this.s = s; }
13 public void close() { try{s.close();}catch(Exception e){throw new StreamException(e);} super.close(); }
14 public int getLocalPort() { return s.getLocalPort(); }
15 public int getRemotePort() { return s.getPort(); }
16 public InetAddress getRemoteAddress() { return ((InetSocketAddress)s.getRemoteSocketAddress()).getAddress(); }
17 public String getRemoteHostname() { return getRemoteAddress().getHostName(); }
18 public String getVirtualHost() { return vhost; }
19 public void setTimeout(int ms) { try { s.setSoTimeout(ms); } catch (Exception e){throw new StreamException(e); }}
20 public void setTcpNoDelay(boolean delay) { try { s.setTcpNoDelay(delay);}catch(Exception e){throw new StreamException(e); }}