    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 * <p>
    037 * <p>
    038 * @see EchoUDPClient
    039 * @see DiscardTCPClient
    040 ***/
    041
    042public final class EchoTCPClient extends DiscardTCPClient
    043{
    044    /*** The default echo port.  It is set to 7 according to RFC 862. ***/
    045    public static final int DEFAULT_PORT = 7;
    046
    047    /***
    048     * The default EchoTCPClient constructor.  It merely sets the default
    049     * port to <code> DEFAULT_PORT </code>.
    050     ***/
    051    public EchoTCPClient ()
    052    {
    053        setDefaultPort(DEFAULT_PORT);
    054    }
    055
    056    /***
    057     * Returns an InputStream from which you may read echoed data from
    058     * the server.  You should NOT close the InputStream when you're finished
    059     * reading from it.  Rather, you should call
    060     * {@link org.apache.commons.net.SocketClient#disconnect  disconnect }
    061     * to clean up properly.
    062     * <p>
    063     * @return An InputStream from which you can read echoed data from the
    064     *         server.
    065     ***/
    066    public InputStream getInputStream()
    067    {
    068        return _input_;
    069    }
    070
    071}