IdDayTimeUDPServer.pas 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. }
  13. {
  14. $Log$
  15. }
  16. {
  17. Rev 1.4 2004.02.03 5:45:04 PM czhower
  18. Name changes
  19. Rev 1.3 1/21/2004 2:12:44 PM JPMugaas
  20. InitComponent
  21. Rev 1.2 10/24/2003 02:54:52 PM JPMugaas
  22. These should now work with the new code.
  23. Rev 1.1 2003.10.24 10:38:24 AM czhower
  24. UDP Server todos
  25. Rev 1.0 11/14/2002 02:17:18 PM JPMugaas
  26. }
  27. unit IdDayTimeUDPServer;
  28. interface
  29. {$i IdCompilerDefines.inc}
  30. uses
  31. Classes,
  32. IdAssignedNumbers, IdGlobal, IdSocketHandle, IdUDPServer;
  33. type
  34. TIdDayTimeUDPServer = class(TIdUDPServer)
  35. protected
  36. FTimeZone : String;
  37. procedure DoUDPRead(AThread: TIdUDPListenerThread; const AData: TIdBytes; ABinding: TIdSocketHandle); override;
  38. public
  39. constructor Create(AOwner: TComponent); override;
  40. published
  41. property TimeZone: String read FTimeZone write FTimeZone;
  42. property DefaultPort default IdPORT_DAYTIME;
  43. end;
  44. implementation
  45. uses
  46. SysUtils;
  47. { TIdDayTimeUDPServer }
  48. constructor TIdDayTimeUDPServer.Create(AOwner: TComponent);
  49. begin
  50. inherited Create(AOwner);
  51. DefaultPort := IdPORT_DAYTIME;
  52. FTimeZone := 'EST'; {Do not Localize}
  53. end;
  54. procedure TIdDayTimeUDPServer.DoUDPRead(AThread: TIdUDPListenerThread;
  55. const AData: TIdBytes; ABinding: TIdSocketHandle);
  56. var
  57. s : String;
  58. begin
  59. inherited DoUDPRead(AThread, AData, ABinding);
  60. s := FormatDateTime('dddd, mmmm dd, yyyy hh:nn:ss', Now) + ' -' + FTimeZone; {Do not Localize}
  61. ABinding.SendTo(ABinding.PeerIP, ABinding.PeerPort, ToBytes(s), ABinding.IPVersion);
  62. end;
  63. end.