[fpc-pascal]INET-Unit: Testing existence of a domain?

Rainer Hantsch rainer at hantsch.co.at
Wed Sep 17 11:54:03 CEST 2003


Hi!

I want to test inside my program if a domain does exist. I am not interested
in the particular domain entries, only in its existence.

For that I tried the following, but it returns always false:

---------------------------------------------------------------
function TestDomain: boolean;
var
   s        :  shortstring;
   sd       :  PChar;
   pn       :  pNetEnt;

begin
   TestDomain:=false;
   DomainFound:=false;

   if pos('@',MailFrom)=0 then exit;	// There cannot be any domain

   s:=Trim(MailFrom); delete(s,1,pos('@',MailFrom));
   if s='' then exit;			// There's still no domain

   s:=s+#0; sd:=@s[1];			// convert to pChar
   pn:=GetNetByName(sd);		// Lookup

   if pn<>nil then			// if not nil, there was an answer.
   begin
      TestDomain:=True;
      DomainFound:=true;
   end;
end;
---------------------------------------------------------------



What am I doing wrong?





mfg

  Ing. Rainer Hantsch






More information about the fpc-pascal mailing list