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