001    /*
002     * Copyright 2001-2005 The Apache Software Foundation
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     *     http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.apache.commons.net;
017    
018    import java.io.InputStream;
019    
020    /***
021     * The EchoTCPClient class is a TCP implementation of a client for the
022     * Echo protocol described in RFC 862.  To use the class, merely
023     * establish a connection with
024     * {@link org.apache.commons.net.SocketClient#connect  connect }
025     * and call {@link DiscardTCPClient#getOutputStream  getOutputStream() } to
026     * retrieve the echo output stream and
027     * {@link #getInputStream getInputStream() }
028     *  to get the echo input stream.
029     * Don't close either stream when you're done using them.  Rather, call
030     * {@link org.apache.commons.net.SocketClient#disconnect  disconnect }
031     * to clean up properly.
032     * <p>
033     * <p>
034     * @author Daniel F. Savarese
035     * @see EchoUDPClient
036     * @see DiscardTCPClient
037     ***/
038    
039    public final class EchoTCPClient extends DiscardTCPClient
040    {
041        /*** The default echo port.  It is set to 7 according to RFC 862. ***/
042        public static final int DEFAULT_PORT = 7;
043    
044        /***
045         * The default EchoTCPClient constructor.  It merely sets the default
046         * port to <code> DEFAULT_PORT </code>.
047         ***/
048        public EchoTCPClient ()
049        {
050            setDefaultPort(DEFAULT_PORT);
051        }
052    
053        /***
054         * Returns an InputStream from which you may read echoed data from
055         * the server.  You should NOT close the InputStream when you're finished
056         * reading from it.  Rather, you should call
057         * {@link org.apache.commons.net.SocketClient#disconnect  disconnect }
058         * to clean up properly.
059         * <p>
060         * @return An InputStream from which you can read echoed data from the
061         *         server.
062         ***/
063        public InputStream getInputStream()
064        {
065            return _input_;
066        }
067    
068    }