IdEchoServer.pas 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. {
  2. $Project$
  3. $Workfile$
  4. $Revision$
  5. $DateUTC$
  6. $Id$
  7. This file is part of the Indy (Internet Direct) project, and is offered
  8. under the dual-licensing agreement described on the Indy website.
  9. (http://www.indyproject.org/)
  10. Copyright:
  11. (c) 1993-2005, Chad Z. Hower and the Indy Pit Crew. All rights reserved.
  12. $Log$
  13. Rev 1.7 12/2/2004 4:23:52 PM JPMugaas
  14. Adjusted for changes in Core.
  15. Rev 1.6 1/21/2004 3:27:48 PM JPMugaas
  16. InitComponent
  17. Rev 1.5 2003.11.29 10:18:54 AM czhower
  18. Updated for core change to InputBuffer.
  19. Rev 1.4 3/6/2003 5:08:50 PM SGrobety
  20. Updated the read buffer methodes to fit the new core (InputBuffer ->
  21. InputBufferAsString + call to CheckForDataOnSource)
  22. Rev 1.3 2/24/2003 08:41:32 PM JPMugaas
  23. Should compile with new code.
  24. Rev 1.2 1/17/2003 05:35:06 PM JPMugaas
  25. Now compiles with new design.
  26. Rev 1.1 1-1-2003 20:13:00 BGooijen
  27. Changed to support the new TIdContext class
  28. Rev 1.0 11/14/2002 02:19:30 PM JPMugaas
  29. 2000-Apr=22 J Peter Mugaas
  30. Ported to Indy
  31. 1999-May-13
  32. Final Version
  33. 2000-Jan-13 MTL
  34. Moved to new Palette Scheme (Winshoes Servers)
  35. }
  36. unit IdEchoServer;
  37. {
  38. Original Author: Ozz Nixon
  39. }
  40. interface
  41. {$i IdCompilerDefines.inc}
  42. uses
  43. IdAssignedNumbers,
  44. IdContext,
  45. IdCustomTCPServer;
  46. Type
  47. TIdECHOServer = class ( TIdCustomTCPServer )
  48. protected
  49. function DoExecute(AContext:TIdContext): boolean; override;
  50. procedure InitComponent; override;
  51. published
  52. property DefaultPort default IdPORT_ECHO;
  53. end;
  54. implementation
  55. uses
  56. IdGlobal, IdIOHandler;
  57. procedure TIdECHOServer.InitComponent;
  58. begin
  59. inherited InitComponent;
  60. DefaultPort := IdPORT_ECHO;
  61. end;
  62. function TIdECHOServer.DoExecute(AContext: TIdContext): Boolean;
  63. var
  64. LBuffer: TIdBytes;
  65. LIOHandler: TIdIOHandler;
  66. begin
  67. Result := True;
  68. SetLength(LBuffer, 0);
  69. LIOHandler := AContext.Connection.IOHandler;
  70. LIOHandler.ReadBytes(LBuffer, -1);
  71. LIOHandler.Write(LBuffer);
  72. end;
  73. end.