KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > net > EchoTCPClient


1 /*
2  * Copyright 2001-2005 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.commons.net;
17
18 import java.io.InputStream JavaDoc;
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 {
41     /*** The default echo port. It is set to 7 according to RFC 862. ***/
42     public static final int DEFAULT_PORT = 7;
43
44     /***
45      * The default EchoTCPClient constructor. It merely sets the default
46      * port to <code> DEFAULT_PORT </code>.
47      ***/

48     public EchoTCPClient ()
49     {
50         setDefaultPort(DEFAULT_PORT);
51     }
52
53     /***
54      * Returns an InputStream from which you may read echoed data from
55      * the server. You should NOT close the InputStream when you're finished
56      * reading from it. Rather, you should call
57      * {@link org.apache.commons.net.SocketClient#disconnect disconnect }
58      * to clean up properly.
59      * <p>
60      * @return An InputStream from which you can read echoed data from the
61      * server.
62      ***/

63     public InputStream JavaDoc getInputStream()
64     {
65         return _input_;
66     }
67
68 }
69
Popular Tags