--- /dev/null
+// HttpMuxConnection.java\r
+// $Id: HttpMuxConnection.java,v 1.1 2010/06/15 12:25:14 smhuang Exp $ \r
+// (c) COPYRIGHT MIT and INRIA, 1997.\r
+// Please first read the full copyright statement in file COPYRIGHT.html\r
+\r
+package org.w3c.www.protocol.http;\r
+\r
+import java.io.IOException;\r
+\r
+import java.net.Socket;\r
+\r
+import org.w3c.www.mux.MuxSession;\r
+import org.w3c.www.mux.MuxStream;\r
+import org.w3c.www.mux.MuxStreamHandler;\r
+\r
+class HttpMuxConnection extends HttpConnection {\r
+ Socket socket = null;\r
+ MuxStream stream = null;\r
+ HttpMuxServer server = null;\r
+ int refcount = 0;\r
+\r
+ protected synchronized boolean incrUseCount() {\r
+ boolean ret = (refcount == 0);\r
+ refcount++;\r
+ return ret;\r
+ }\r
+\r
+ protected synchronized boolean decrUseCount() {\r
+ return (--refcount == 0);\r
+ }\r
+\r
+ public void close() {\r
+ try {\r
+ stream.shutdown(true);\r
+ } catch (IOException ex) {\r
+ ex.printStackTrace();\r
+ }\r
+ }\r
+\r
+ public final MuxSession connect(int protid) \r
+ throws IOException\r
+ {\r
+ return stream.connect(protid);\r
+ }\r
+\r
+ HttpMuxConnection(HttpMuxServer server, String host, int port) \r
+ throws IOException\r
+ {\r
+ this.server = server;\r
+ this.socket = new Socket(host, port);\r
+ this.stream = new MuxStream(false, null, socket);\r
+ }\r
+\r
+}\r