1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.net;
  17. import java.io.InputStream;
  18. /***
  19. * The CharGenTCPClient class is a TCP implementation of a client for the
  20. * character generator protocol described in RFC 864. It can also be
  21. * used for Systat (RFC 866), Quote of the Day (RFC 865), and netstat
  22. * (port 15). All of these protocols involve connecting to the appropriate
  23. * port, and reading data from an input stream. The chargen protocol
  24. * actually sends data until the receiving end closes the connection. All
  25. * of the others send only a fixed amount of data and then close the
  26. * connection.
  27. * <p>
  28. * To use the CharGenTCPClient class, just establish a
  29. * connection with
  30. * <a href="org.apache.commons.net.SocketClient.html#connect"> connect </a>
  31. * and call <a href="#getInputStream"> getInputStream() </a> to access
  32. * the data. Don't close the input stream when you're done with it. Rather,
  33. * call <a href="org.apache.commons.net.SocketClient.html#disconnect"> disconnect </a>
  34. * to clean up properly.
  35. * <p>
  36. * <p>
  37. * @author Daniel F. Savarese
  38. * @see CharGenUDPClient
  39. ***/
  40. public final class CharGenTCPClient extends SocketClient
  41. {
  42. /*** The systat port value of 11 according to RFC 866. ***/
  43. public static final int SYSTAT_PORT = 11;
  44. /*** The netstat port value of 19. ***/
  45. public static final int NETSTAT_PORT = 15;
  46. /*** The quote of the day port value of 17 according to RFC 865. ***/
  47. public static final int QUOTE_OF_DAY_PORT = 17;
  48. /*** The character generator port value of 19 according to RFC 864. ***/
  49. public static final int CHARGEN_PORT = 19;
  50. /*** The default chargen port. It is set to 19 according to RFC 864. ***/
  51. public static final int DEFAULT_PORT = 19;
  52. /***
  53. * The default constructor for CharGenTCPClient. It merely sets the
  54. * default port to <code> DEFAULT_PORT </code>.
  55. ***/
  56. public CharGenTCPClient ()
  57. {
  58. setDefaultPort(DEFAULT_PORT);
  59. }
  60. /***
  61. * Returns an InputStream from which the server generated data can be
  62. * read. You should NOT close the InputStream when you're finished
  63. * reading from it. Rather, you should call
  64. * <a href="org.apache.commons.net.SocketClient.html#disconnect"> disconnect </a>
  65. * to clean up properly.
  66. * <p>
  67. * @return An InputStream from which the server generated data can be read.
  68. ***/
  69. public InputStream getInputStream()
  70. {
  71. return _input_;
  72. }
  73. }