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 Echo protocol described in RFC 862. To use the class, merely establish a connection with 026 * {@link org.apache.commons.net.SocketClient#connect connect } and call {@link DiscardTCPClient#getOutputStream getOutputStream() } to retrieve the echo output 027 * stream and {@link #getInputStream getInputStream() } to get the echo input stream. Don't close either stream when you're done using them. Rather, call 028 * {@link org.apache.commons.net.SocketClient#disconnect disconnect } to clean up properly. 029 * 030 * @see EchoUDPClient 031 * @see DiscardTCPClient 032 */ 033 034public final class EchoTCPClient extends DiscardTCPClient { 035 /** The default echo port. It is set to 7 according to RFC 862. */ 036 public static final int DEFAULT_PORT = 7; 037 038 /** 039 * The default EchoTCPClient constructor. It merely sets the default port to <code>DEFAULT_PORT</code>. 040 */ 041 public EchoTCPClient() { 042 setDefaultPort(DEFAULT_PORT); 043 } 044 045 /** 046 * Returns an InputStream from which you may read echoed data from the server. You should NOT close the InputStream when you're finished reading from it. 047 * Rather, you should call {@link org.apache.commons.net.SocketClient#disconnect disconnect } to clean up properly. 048 * 049 * @return An InputStream from which you can read echoed data from the server. 050 */ 051 public InputStream getInputStream() { 052 return _input_; 053 } 054 055}