That's very similar to what I had just come up with, and unfortunately we
now have the next strange problem.

This returns a message from whatismyip.com saying that I have been banned
for 5 minutes for hitting the site too often. If I instantly revert back to
the Indy component, it works.

Is there something else I should set to prevent this response?

Graham

-----Original Message-----
From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
Behalf Of Francois PIETTE
Sent: 13 September 2010 16:22
To: ICS support mailing
Subject: Re: [twsocket] ICS - What Is My IP

> By using the Indy TIdHTTP and TIdIOHandlerStack it is very easy to use 
> these components to call 
> http://www.whatismyip.com/automation/n09230945.asp to return the 
> Internet IP address. What I want to know is, what is the simplest way 
> to do this with the ICS components. The Indy components always seem 
> not to be as robust as they could be.
> Is there an ICS example somewhere?

Here it is (not tested):

procedure TForm1.Button1Click(Sender: TObject); begin
    HttpCli1.Url := 'http://www.whatismyip.com/automation/n09230945.asp';
    Httpcli1.RcvdStream := TMemoryStream.Create;
    HttpCli1.GetASync;
end;

procedure TForm1.HttpCli1RequestDone(Sender: TObject; RqType: THttpRequest;
  ErrCode: Word);
var
    Buf : AnsiString;
begin
    if ErrCode <> 0 then
        Memo1.Lines.Add('Failed ' + IntToStr(ErrCode))
    else if HttpCli1.StatusCode <> 200 then
        Memo1.Lines.Add('Failed. ' + IntToStr(HttpCli1.StatusCode) + ' ' +
HttpCli1.ReasonPhrase)
    else begin
        SetLength(Buf, HttpCli1.RcvdStream.Size);
        Move(PAnsiChar(TMemoryStream(HttpCli1.RcvdStream).Memory)^, Buf[1],
Length(Buf));
        Memo1.Lines.Add(Buf);
    end;
    HttpCli1.RcvdStream.Free;
end;

--
francois.pie...@overbyte.be
The author of the freeware multi-tier middleware MidWare The author of the
freeware Internet Component Suite (ICS) http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list please goto
http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to