IdWhois.pas 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 1/21/2004 4:21:16 PM JPMugaas
  18. InitComponent
  19. Rev 1.3 2/24/2003 10:39:56 PM JPMugaas
  20. Rev 1.2 12/8/2002 07:26:16 PM JPMugaas
  21. Added published host and port properties.
  22. Rev 1.1 12/6/2002 05:30:50 PM JPMugaas
  23. Now decend from TIdTCPClientCustom instead of TIdTCPClient.
  24. Rev 1.0 11/13/2002 08:04:40 AM JPMugaas
  25. }
  26. unit IdWhois;
  27. {
  28. 2000-May-30 J. Peter Mugaas
  29. -made modifications so OnWork event will work for this component
  30. 2000-Apr-17 Kudzu
  31. -Converted to Indy
  32. 2000-Jan-13 MTL
  33. -Moved to new Palette Scheme (Winshoes Servers)
  34. 1999-Jan-05 - Kudzu
  35. -Cleaned uses clause
  36. -Changed result type
  37. -Eliminated Response prop
  38. -Fixed a bug in Whois
  39. -Added Try..finally
  40. -Other various mods
  41. Original Author: Hadi Hariri
  42. }
  43. interface
  44. {$i IdCompilerDefines.inc}
  45. uses
  46. {$IFDEF WORKAROUND_INLINE_CONSTRUCTORS}
  47. Classes,
  48. {$ENDIF}
  49. IdAssignedNumbers,
  50. IdTCPClient;
  51. type
  52. TIdWhois = class(TIdTCPClientCustom)
  53. protected
  54. procedure InitComponent; override;
  55. public
  56. {$IFDEF WORKAROUND_INLINE_CONSTRUCTORS}
  57. constructor Create(AOwner: TComponent); reintroduce; overload;
  58. {$ENDIF}
  59. function WhoIs(const ADomain: string): string;
  60. published
  61. property Port default IdPORT_WHOIS;
  62. property Host;
  63. end;
  64. implementation
  65. uses
  66. IdGlobal,
  67. IdTCPConnection;
  68. { TIdWHOIS }
  69. {$IFDEF WORKAROUND_INLINE_CONSTRUCTORS}
  70. constructor TIdWHOIS.Create(AOwner: TComponent);
  71. begin
  72. inherited Create(AOwner);
  73. end;
  74. {$ENDIF}
  75. procedure TIdWHOIS.InitComponent;
  76. begin
  77. inherited;
  78. Host := 'whois.internic.net'; {Do not Localize}
  79. Port := IdPORT_WHOIS;
  80. end;
  81. function TIdWHOIS.WhoIs(const ADomain: string): string;
  82. begin
  83. Connect; try
  84. IOHandler.WriteLn(ADomain);
  85. Result := IOHandler.AllData;
  86. finally Disconnect; end;
  87. end;
  88. end.