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

Reply via email to