001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: *
015: * See the License for the specific language governing permissions and
016: * limitations under the License.
017: */
018:
019: /**
020: * @author Mikhail A. Markov
021: * @version $Revision: 1.1.2.3 $
022: */package org.apache.harmony.rmi.transport;
023:
024: import java.io.InputStream;
025: import java.io.IOException;
026: import java.io.OutputStream;
027: import java.net.InetAddress;
028: import java.net.Socket;
029: import java.net.SocketAddress;
030: import java.net.SocketException;
031:
032: /**
033: * Wrapper for already opened socket.
034: * It just translates all requests to the underlying socket.
035: *
036: * @author Mikhail A. Markov
037: * @version $Revision: 1.1.2.3 $
038: */
039: public class SocketWrapper extends Socket {
040:
041: protected Socket s;
042: protected InputStream in;
043: protected OutputStream out;
044:
045: protected SocketWrapper(Socket s) throws IOException {
046: this (s, null, null);
047: }
048:
049: public SocketWrapper(Socket s, InputStream in, OutputStream out)
050: throws IOException {
051: this .s = s;
052: this .in = (in == null) ? s.getInputStream() : in;
053: this .out = (out == null) ? s.getOutputStream() : out;
054: }
055:
056: public void connect(SocketAddress endpoint) throws IOException {
057: s.connect(endpoint);
058: }
059:
060: public void connect(SocketAddress endpoint, int timeout)
061: throws IOException {
062: s.connect(endpoint, timeout);
063: }
064:
065: public void bind(SocketAddress bindpoint) throws IOException {
066: s.bind(bindpoint);
067: }
068:
069: public InetAddress getInetAddress() {
070: return s.getInetAddress();
071: }
072:
073: public InetAddress getLocalAddress() {
074: return s.getLocalAddress();
075: }
076:
077: public int getPort() {
078: return s.getPort();
079: }
080:
081: public int getLocalPort() {
082: return s.getLocalPort();
083: }
084:
085: public SocketAddress getRemoteSocketAddress() {
086: return s.getRemoteSocketAddress();
087: }
088:
089: public SocketAddress getLocalSocketAddress() {
090: return s.getLocalSocketAddress();
091: }
092:
093: //public SocketChannel getChannel() {
094: // return s.getChannel();
095: //}
096:
097: public InputStream getInputStream() throws IOException {
098: return in;
099: }
100:
101: public OutputStream getOutputStream() throws IOException {
102: return out;
103: }
104:
105: public void setTcpNoDelay(boolean on) throws SocketException {
106: s.setTcpNoDelay(on);
107: }
108:
109: public boolean getTcpNoDelay() throws SocketException {
110: return s.getTcpNoDelay();
111: }
112:
113: public void setSoLinger(boolean on, int linger)
114: throws SocketException {
115: s.setSoLinger(on, linger);
116: }
117:
118: public int getSoLinger() throws SocketException {
119: return s.getSoLinger();
120: }
121:
122: public void sendUrgentData(int data) throws IOException {
123: s.sendUrgentData(data);
124: }
125:
126: public void setOOBInline(boolean on) throws SocketException {
127: s.setOOBInline(on);
128: }
129:
130: public boolean getOOBInline() throws SocketException {
131: return s.getOOBInline();
132: }
133:
134: public void setSoTimeout(int timeout) throws SocketException {
135: s.setSoTimeout(timeout);
136: }
137:
138: public int getSoTimeout() throws SocketException {
139: return s.getSoTimeout();
140: }
141:
142: public void setSendBufferSize(int size) throws SocketException {
143: s.setSendBufferSize(size);
144: }
145:
146: public int getSendBufferSize() throws SocketException {
147: return s.getSendBufferSize();
148: }
149:
150: public void setReceiveBufferSize(int size) throws SocketException {
151: s.setReceiveBufferSize(size);
152: }
153:
154: public int getReceiveBufferSize() throws SocketException {
155: return s.getReceiveBufferSize();
156: }
157:
158: public void setKeepAlive(boolean on) throws SocketException {
159: s.setKeepAlive(on);
160: }
161:
162: public boolean getKeepAlive() throws SocketException {
163: return s.getKeepAlive();
164: }
165:
166: public void setTrafficClass(int tc) throws SocketException {
167: s.setTrafficClass(tc);
168: }
169:
170: public int getTrafficClass() throws SocketException {
171: return s.getTrafficClass();
172: }
173:
174: public void setReuseAddress(boolean on) throws SocketException {
175: s.setReuseAddress(on);
176: }
177:
178: public boolean getReuseAddress() throws SocketException {
179: return s.getReuseAddress();
180: }
181:
182: public void close() throws IOException {
183: s.close();
184: }
185:
186: public void shutdownInput() throws IOException {
187: s.shutdownInput();
188: }
189:
190: public void shutdownOutput() throws IOException {
191: s.shutdownOutput();
192: }
193:
194: public String toString() {
195: return s.toString();
196: }
197:
198: public boolean isConnected() {
199: return s.isConnected();
200: }
201:
202: public boolean isBound() {
203: return s.isBound();
204: }
205:
206: public boolean isClosed() {
207: return s.isClosed();
208: }
209:
210: public boolean isInputShutdown() {
211: return s.isInputShutdown();
212: }
213:
214: public boolean isOutputShutdown() {
215: return s.isOutputShutdown();
216: }
217: }
|