001: /*
002: * <copyright>
003: *
004: * Copyright 1997-2004 BBNT Solutions, LLC
005: * under sponsorship of the Defense Advanced Research Projects
006: * Agency (DARPA).
007: *
008: * You can redistribute this software and/or modify it under the
009: * terms of the Cougaar Open Source License as published on the
010: * Cougaar Open Source Website (www.cougaar.org).
011: *
012: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
013: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
014: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
015: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
016: * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
017: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
018: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
019: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
020: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
021: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
022: * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
023: *
024: * </copyright>
025: */
026:
027: package org.cougaar.mts.base;
028:
029: import java.io.IOException;
030: import java.io.InputStream;
031: import java.io.OutputStream;
032: import java.net.InetAddress;
033: import java.net.Socket;
034: import java.net.SocketAddress;
035: import java.net.SocketException;
036: import java.nio.channels.SocketChannel;
037:
038: /**
039: * This class is a delegating {@link Socket} that simply passes all
040: * methods to another socket. It's handy as a base class for Socket
041: * aspect delegates, as attached by the {@link SocketFactory}.
042: */
043: abstract public class SocketDelegateImplBase extends Socket {
044: private Socket socket;
045:
046: protected SocketDelegateImplBase(Socket socket) {
047: this .socket = socket;
048: }
049:
050: public void sendUrgentData(int data) throws java.io.IOException {
051: socket.sendUrgentData(data);
052: }
053:
054: public void bind(SocketAddress bindpoint)
055: throws java.io.IOException {
056: socket.bind(bindpoint);
057: }
058:
059: public void connect(SocketAddress endpoint)
060: throws java.io.IOException {
061: socket.connect(endpoint);
062: }
063:
064: public void connect(SocketAddress endpoint, int timeout)
065: throws java.io.IOException {
066: socket.connect(endpoint, timeout);
067: }
068:
069: public SocketChannel getChannel() {
070: return socket.getChannel();
071: }
072:
073: public SocketAddress getLocalSocketAddress() {
074: return socket.getLocalSocketAddress();
075: }
076:
077: public SocketAddress getRemoteSocketAddress() {
078: return socket.getRemoteSocketAddress();
079: }
080:
081: public boolean getOOBInline() throws SocketException {
082: return socket.getOOBInline();
083: }
084:
085: public void setOOBInline(boolean on) throws SocketException {
086: socket.setOOBInline(on);
087: }
088:
089: public boolean getReuseAddress() throws SocketException {
090: return socket.getReuseAddress();
091: }
092:
093: public void setReuseAddress(boolean on) throws SocketException {
094: socket.setReuseAddress(on);
095: }
096:
097: public int getTrafficClass() throws SocketException {
098: return socket.getTrafficClass();
099: }
100:
101: public void setTrafficClass(int tc) throws SocketException {
102: socket.setTrafficClass(tc);
103: }
104:
105: public boolean isBound() {
106: return socket.isBound();
107: }
108:
109: public boolean isClosed() {
110: return socket.isClosed();
111: }
112:
113: public boolean isConnected() {
114: return socket.isConnected();
115: }
116:
117: public boolean isInputShutdown() {
118: return socket.isInputShutdown();
119: }
120:
121: public boolean isOutputShutdown() {
122: return socket.isOutputShutdown();
123: }
124:
125: public InetAddress getInetAddress() {
126: return socket.getInetAddress();
127: }
128:
129: public InetAddress getLocalAddress() {
130: return socket.getLocalAddress();
131: }
132:
133: public int getPort() {
134: return socket.getPort();
135: }
136:
137: public int getLocalPort() {
138: return socket.getLocalPort();
139: }
140:
141: public InputStream getInputStream() throws IOException {
142: return socket.getInputStream();
143: }
144:
145: public OutputStream getOutputStream() throws IOException {
146: return socket.getOutputStream();
147: }
148:
149: public void setTcpNoDelay(boolean flag) throws SocketException {
150: socket.setTcpNoDelay(flag);
151: }
152:
153: public boolean getTcpNoDelay() throws SocketException {
154: return socket.getTcpNoDelay();
155: }
156:
157: public void setSoLinger(boolean flag, int linger)
158: throws SocketException {
159: socket.setSoLinger(flag, linger);
160: }
161:
162: public int getSoLinger() throws SocketException {
163: return socket.getSoLinger();
164: }
165:
166: public void setSoTimeout(int timeout) throws SocketException {
167: socket.setSoTimeout(timeout);
168: }
169:
170: public int getSoTimeout() throws SocketException {
171: return socket.getSoTimeout();
172: }
173:
174: public void setSendBufferSize(int size) throws SocketException {
175: socket.setSendBufferSize(size);
176: }
177:
178: public int getSendBufferSize() throws SocketException {
179: return socket.getSendBufferSize();
180: }
181:
182: public void setReceiveBufferSize(int size) throws SocketException {
183: socket.setReceiveBufferSize(size);
184: }
185:
186: public int getReceiveBufferSize() throws SocketException {
187: return socket.getReceiveBufferSize();
188: }
189:
190: public void setKeepAlive(boolean flag) throws SocketException {
191: socket.setKeepAlive(flag);
192: }
193:
194: public boolean getKeepAlive() throws SocketException {
195: return socket.getKeepAlive();
196: }
197:
198: public void close() throws IOException {
199: socket.close();
200: }
201:
202: public void shutdownInput() throws IOException {
203: socket.shutdownInput();
204: }
205:
206: public void shutdownOutput() throws IOException {
207: socket.shutdownOutput();
208: }
209:
210: public String toString() {
211: return socket.toString();
212: }
213:
214: }
|