No Timeout for IdWhois

Giganews Newsgroups
Subject: No Timeout for IdWhois
Posted by:  Jason Trahan (jason.trah…@xspedius.com)
Date: Tue, 8 Jul 2003

I noticed that in IdWhois there is no timeout settings and this causes the
program to lock up whenever there is an actual timeout. I modified the
source and I thought I would post it here so that others can see it. I hope
whoever has control of the source code sees it and puts it in Version 10.

uses
Classes,
  IdAssignedNumbers,
  IdTCPClient;

type
  TIdWhois = class(TIdTCPClient)
  public
    constructor Create(AOwner: TComponent); override;
    function WhoIs(const ADomain: string): string; overload;
    function WhoIs(const ADomain: string; const ATimeout: Integer): String;
overload;
  end;

implementation

uses
  IdGlobal,
  IdTCPConnection;

{ TIdWHOIS }

constructor TIdWHOIS.Create(AOwner: TComponent);
begin
  inherited;
  Host := 'whois.internic.net';    {Do not Localize}
  Port := IdPORT_WHOIS;
end;

function TIdWHOIS.WhoIs(const ADomain: string): string;
begin
  Whois(ADomain, IdTimeoutDefault);
end;

function TIdWhois.WhoIs(const ADomain: string;
  const ATimeout: Integer): String;
begin
  try
    Connect(ATimeout);
  except
    raise;
  end;
  try
    WriteLn(ADomain);
    ReadTimeout := ATimeOut;
    Result := AllData;
  finally Disconnect; end;
end;

Replies