01: // HttpMuxConnection.java
02: // $Id: HttpMuxConnection.java,v 1.4 2000/08/16 21:38:02 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1997.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.www.protocol.http;
07:
08: import java.io.IOException;
09:
10: import java.net.Socket;
11:
12: import org.w3c.www.mux.MuxSession;
13: import org.w3c.www.mux.MuxStream;
14: import org.w3c.www.mux.MuxStreamHandler;
15:
16: class HttpMuxConnection extends HttpConnection {
17: Socket socket = null;
18: MuxStream stream = null;
19: HttpMuxServer server = null;
20: int refcount = 0;
21:
22: protected synchronized boolean incrUseCount() {
23: boolean ret = (refcount == 0);
24: refcount++;
25: return ret;
26: }
27:
28: protected synchronized boolean decrUseCount() {
29: return (--refcount == 0);
30: }
31:
32: public void close() {
33: try {
34: stream.shutdown(true);
35: } catch (IOException ex) {
36: ex.printStackTrace();
37: }
38: }
39:
40: public final MuxSession connect(int protid) throws IOException {
41: return stream.connect(protid);
42: }
43:
44: HttpMuxConnection(HttpMuxServer server, String host, int port)
45: throws IOException {
46: this .server = server;
47: this .socket = new Socket(host, port);
48: this .stream = new MuxStream(false, null, socket);
49: }
50:
51: }
|