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 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017
018package org.apache.commons.net.echo;
019
020import java.io.InputStream;
021
022import org.apache.commons.net.discard.DiscardTCPClient;
023
024/**
025 * The EchoTCPClient class is a TCP implementation of a client for the
026 * Echo protocol described in RFC 862.  To use the class, merely
027 * establish a connection with
028 * {@link org.apache.commons.net.SocketClient#connect  connect }
029 * and call {@link DiscardTCPClient#getOutputStream  getOutputStream() } to
030 * retrieve the echo output stream and
031 * {@link #getInputStream getInputStream() }
032 *  to get the echo input stream.
033 * Don't close either stream when you're done using them.  Rather, call
034 * {@link org.apache.commons.net.SocketClient#disconnect  disconnect }
035 * to clean up properly.
036 *
037 * @see EchoUDPClient
038 * @see DiscardTCPClient
039 */
040
041public final class EchoTCPClient extends DiscardTCPClient
042{
043    /** The default echo port.  It is set to 7 according to RFC 862. */
044    public static final int DEFAULT_PORT = 7;
045
046    /**
047     * The default EchoTCPClient constructor.  It merely sets the default
048     * port to <code> DEFAULT_PORT </code>.
049     */
050    public EchoTCPClient ()
051    {
052        setDefaultPort(DEFAULT_PORT);
053    }
054
055    /**
056     * Returns an InputStream from which you may read echoed data from
057     * the server.  You should NOT close the InputStream when you're finished
058     * reading from it.  Rather, you should call
059     * {@link org.apache.commons.net.SocketClient#disconnect  disconnect }
060     * to clean up properly.
061     *
062     * @return An InputStream from which you can read echoed data from the
063     *         server.
064     */
065    public InputStream getInputStream()
066    {
067        return _input_;
068    }
069
070}