KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > transport > http > SocketInputStream


1 /*
2  * Copyright 2001-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.axis.transport.http;
17
18
19 import java.io.IOException JavaDoc;
20 import java.io.InputStream JavaDoc;
21
22
23 /**
24  *
25  * @author Rick Rineholt
26  */

27
28  /**
29   * The ONLY reason for this is so we can clean up sockets quicker/cleaner.
30   */

31
32
33 public class SocketInputStream extends java.io.FilterInputStream JavaDoc {
34     protected volatile boolean closed = false;
35     java.net.Socket JavaDoc socket= null;
36
37     private SocketInputStream() {
38         super(null);
39     }
40
41
42     public SocketInputStream(InputStream JavaDoc is, java.net.Socket JavaDoc socket) {
43         super(is);
44         this.socket= socket;
45     }
46
47     public void close() throws IOException JavaDoc {
48        synchronized(this){
49        if(closed) return;
50        closed= true;
51        }
52        in.close();
53        in= null;
54        socket.close();
55        socket= null;
56     }
57 }
58
Popular Tags