1 // Copyright 2000-2005 the Contributors, as shown in the revision logs.
2 // Licensed under the Apache Public Source License 2.0 ("the License").
3 // You may not use this file except in compliance with the License.
9 import org.ibex.util.*;
11 /** a stream backed by a socket */
12 public class Connection extends Stream {
13 private final Socket s;
14 public final String vhost;
15 public Connection(Socket s, String vhost) { super(s); this.vhost = vhost; this.s = s; }
16 public void close() { try{s.close();}catch(Exception e){throw new Stream.StreamException(e);} super.close(); }
17 public int getLocalPort() { return s.getLocalPort(); }
18 public InetAddress getLocalAddress() { return ((InetSocketAddress)s.getLocalSocketAddress()).getAddress(); }
19 public int getRemotePort() { return s.getPort(); }
20 public InetAddress getRemoteAddress() { return ((InetSocketAddress)s.getRemoteSocketAddress()).getAddress(); }
21 public String getRemoteHostname() { return getRemoteAddress().getHostName(); }
22 public String getVirtualHost() { return vhost; }
23 public void setTimeout(int ms) { try { s.setSoTimeout(ms); } catch (Exception e){throw new Stream.StreamException(e); }}
24 public void setTcpNoDelay(boolean delay) { try { s.setTcpNoDelay(delay);}catch(Exception e){throw new Stream.StreamException(e); }}