01: /*
02: * Copyright 2001-2005 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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.commons.net;
17:
18: import java.io.InputStream;
19:
20: /***
21: * The EchoTCPClient class is a TCP implementation of a client for the
22: * Echo protocol described in RFC 862. To use the class, merely
23: * establish a connection with
24: * {@link org.apache.commons.net.SocketClient#connect connect }
25: * and call {@link DiscardTCPClient#getOutputStream getOutputStream() } to
26: * retrieve the echo output stream and
27: * {@link #getInputStream getInputStream() }
28: * to get the echo input stream.
29: * Don't close either stream when you're done using them. Rather, call
30: * {@link org.apache.commons.net.SocketClient#disconnect disconnect }
31: * to clean up properly.
32: * <p>
33: * <p>
34: * @author Daniel F. Savarese
35: * @see EchoUDPClient
36: * @see DiscardTCPClient
37: ***/
38:
39: public final class EchoTCPClient extends DiscardTCPClient {
40: /*** The default echo port. It is set to 7 according to RFC 862. ***/
41: public static final int DEFAULT_PORT = 7;
42:
43: /***
44: * The default EchoTCPClient constructor. It merely sets the default
45: * port to <code> DEFAULT_PORT </code>.
46: ***/
47: public EchoTCPClient() {
48: setDefaultPort(DEFAULT_PORT);
49: }
50:
51: /***
52: * Returns an InputStream from which you may read echoed data from
53: * the server. You should NOT close the InputStream when you're finished
54: * reading from it. Rather, you should call
55: * {@link org.apache.commons.net.SocketClient#disconnect disconnect }
56: * to clean up properly.
57: * <p>
58: * @return An InputStream from which you can read echoed data from the
59: * server.
60: ***/
61: public InputStream getInputStream() {
62: return _input_;
63: }
64:
65: }
|