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 Socket getSocket() { return s; }
17 public void close() { try{s.close();}catch(Exception e){throw new Stream.StreamException(e);} super.close(); }
18 public int getLocalPort() { return s.getLocalPort(); }
19 public InetAddress getLocalAddress() { return ((InetSocketAddress)s.getLocalSocketAddress()).getAddress(); }
20 public int getRemotePort() { return s.getPort(); }
21 public InetAddress getRemoteAddress() { return ((InetSocketAddress)s.getRemoteSocketAddress()).getAddress(); }
22 public String getRemoteHostname() { return getRemoteAddress().getHostName(); }
23 public String getVirtualHost() { return vhost; }
24 public void setTimeout(int ms) { try { s.setSoTimeout(ms); } catch (Exception e){throw new Stream.StreamException(e); }}
25 public void setTcpNoDelay(boolean delay) { try { s.setTcpNoDelay(delay);}catch(Exception e){throw new Stream.StreamException(e); }}