Nick wrote: > Arno, > > I know waiting in a loop is not the best way, but how else can I do it? > I have a list of 4 domains that I want to get the ip address for.. >
procedure TForm1.Button1Click(Sender: TObject); begin MyHostList.Add('mail.gmx.de'); MyHostList.Add('pop.gmx.de'); WSocket1.DnsLookup(MyHostList[0]); end; procedure TForm1.WSocket1DnsLookupDone(Sender: TObject; ErrCode: Word); begin if ErrCode = 0 then Memo1.Lines.Add(WSocket1.DnsResult) else Memo1.Lines.Add(WSocketErrorDesc(ErrCode)); if MyHostList.Count > 0 then MyHostList.Delete(0); if MyHostList.Count > 0 then WSocket1.DnsLookup(MyHostList[0]); end; >> >> Message: 3 >> Date: Wed, 21 Sep 2005 15:56:42 +0200 >> From: "Arno Garrels" <[EMAIL PROTECTED]> >> Subject: Re: [twsocket] Using WSocket to get ip of domain >> To: "ICS support mailing" <twsocket@elists.org> >> Message-ID: <[EMAIL PROTECTED]> >> Content-Type: text/plain; charset="iso-8859-1" >> >> Don't wait in a loop. Event OnDnsLookupDone is fired after the lookup >> has finished. >> >> Arno Garrels >> >> Nick wrote: >>> But if you enter an invalid domain, or if you are not connected to the >>> internet, no error is raised. I even wrote my own timer function to >>> abort the process after 10 seconds but that doesn't work either. >>> >>> sIP is a global string >>> >>> Button1 click >>> >>> sIP := ''; >>> WSocket1.Addr:= edSite.text; >>> WSocket1.DnsLookup(edSite.text); >>> While sIP = '' do >>> Application.ProcessMessages; >>> edIP.text := sIP; >>> //======== >>> >>> And with WsockectDone event >>> If Error<>0 then >>> sIP := 'Error retrieving' >>> else >>> sIP := WSocket1.DnsResult; >>> //========= >>> >>> This works 90% of the time, but if the connection dies or the domain is >>> invalid (like aaazzzzbbb.com) then it hangs totaly. >>> >>> Thanks alot :-) >>> Nick >> >> >> ------------------------------ -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be