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 CharGenTCPClient class is a TCP implementation of a client for the
022     * character generator protocol described in RFC 864.  It can also be
023     * used for Systat (RFC 866), Quote of the Day (RFC 865), and netstat
024     * (port 15).  All of these protocols involve connecting to the appropriate
025     * port, and reading data from an input stream.  The chargen protocol
026     * actually sends data until the receiving end closes the connection.  All
027     * of the others send only a fixed amount of data and then close the
028     * connection.
029     * <p>
030     * To use the CharGenTCPClient class, just establish a
031     * connection with
032     * {@link org.apache.commons.net.SocketClient#connect  connect }
033     * and call {@link #getInputStream  getInputStream() } to access
034     * the data.  Don't close the input stream when you're done with it.  Rather,
035     * call {@link org.apache.commons.net.SocketClient#disconnect  disconnect }
036     * to clean up properly.
037     * <p>
038     * <p>
039     * @author Daniel F. Savarese
040     * @see CharGenUDPClient
041     ***/
042    
043    public final class CharGenTCPClient extends SocketClient
044    {
045        /*** The systat port value of 11 according to RFC 866. ***/
046        public static final int SYSTAT_PORT = 11;
047        /*** The netstat port value of 19. ***/
048        public static final int NETSTAT_PORT = 15;
049        /*** The quote of the day port value of 17 according to RFC 865. ***/
050        public static final int QUOTE_OF_DAY_PORT = 17;
051        /*** The character generator port value of 19 according to RFC 864. ***/
052        public static final int CHARGEN_PORT = 19;
053        /*** The default chargen port.  It is set to 19 according to RFC 864. ***/
054        public static final int DEFAULT_PORT = 19;
055    
056        /***
057         * The default constructor for CharGenTCPClient.  It merely sets the
058         * default port to <code> DEFAULT_PORT </code>.
059         ***/
060        public CharGenTCPClient ()
061        {
062            setDefaultPort(DEFAULT_PORT);
063        }
064    
065        /***
066         * Returns an InputStream from which the server generated data can be
067         * read.  You should NOT close the InputStream when you're finished
068         * reading from it.  Rather, you should call
069         * {@link org.apache.commons.net.SocketClient#disconnect  disconnect }
070         * to clean up properly.
071         * <p>
072         * @return An InputStream from which the server generated data can be read.
073         ***/
074        public InputStream getInputStream()
075        {
076            return _input_;
077        }
078    }
079    
080    
081    
082