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 EchoTCPClient class is a TCP implementation of a client for the
  20. * Echo protocol described in RFC 862. To use the class, merely
  21. * establish a connection with
  22. * <a href="org.apache.commons.net.SocketClient.html#connect"> connect </a>
  23. * and call <a href="#getOutputStream"> getOutputStream() </a> to
  24. * retrieve the echo output stream and
  25. * <a href="org.apache.commons.net.DiscardTCPClient.html#getInputStream">
  26. * getInputStream() </a> to get the echo input stream.
  27. * Don't close either stream when you're done using them. Rather, call
  28. * <a href="org.apache.commons.net.SocketClient.html#disconnect"> disconnect </a>
  29. * to clean up properly.
  30. * <p>
  31. * <p>
  32. * @author Daniel F. Savarese
  33. * @see EchoUDPClient
  34. * @see DiscardTCPClient
  35. ***/
  36. public final class EchoTCPClient extends DiscardTCPClient
  37. {
  38. /*** The default echo port. It is set to 7 according to RFC 862. ***/
  39. public static final int DEFAULT_PORT = 7;
  40. /***
  41. * The default EchoTCPClient constructor. It merely sets the default
  42. * port to <code> DEFAULT_PORT </code>.
  43. ***/
  44. public EchoTCPClient ()
  45. {
  46. setDefaultPort(DEFAULT_PORT);
  47. }
  48. /***
  49. * Returns an InputStream from which you may read echoed data from
  50. * the server. You should NOT close the InputStream when you're finished
  51. * reading from it. Rather, you should call
  52. * <a href="org.apache.commons.net.SocketClient.html#disconnect"> disconnect </a>
  53. * to clean up properly.
  54. * <p>
  55. * @return An InputStream from which you can read echoed data from the
  56. * server.
  57. ***/
  58. public InputStream getInputStream()
  59. {
  60. return _input_;
  61. }
  62. }