Re: [twsocket] ICS - What Is My IP

2010-09-13 Thread Angus Robertson - Magenta Systems Ltd
> Is there an ICS example somewhere?

There are dozens of example ICS programs, and several that demonstrate
various aspects of the HTTP client component, accessing a simple web page
is about as easy as it gets. 

Angus

--
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


Re: [twsocket] ICS - What Is My IP

2010-09-13 Thread Graham Powell
Easy when you know how. The only demo programs I can find are what were
installed with the ICS and none of them seem to tell me what I need to know.

I am doing this:

  HttpCli1.Url := 'http://www.whatismyip.com/automation/n09230945.asp';
  HttpCli1.GetAsync; 

This returns with the RequestDone event, an ErrorCode of 0 and the correct
RqType, but now what?

Graham

-Original Message-
From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
Behalf Of Angus Robertson - Magenta Systems Ltd
Sent: 13 September 2010 14:39
To: twsocket@elists.org
Subject: Re: [twsocket] ICS - What Is My IP

> Is there an ICS example somewhere?

There are dozens of example ICS programs, and several that demonstrate
various aspects of the HTTP client component, accessing a simple web page is
about as easy as it gets. 

Angus

--
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


Re: [twsocket] ICS - What Is My IP

2010-09-13 Thread Fastream Technologies
Hi,

You should have a look at the httptst demo. You need to assign the
receivedstream and read the data in requestdone.

Regards,

SZ

On Mon, Sep 13, 2010 at 5:43 PM, Graham Powell wrote:

> Easy when you know how. The only demo programs I can find are what were
> installed with the ICS and none of them seem to tell me what I need to
> know.
>
> I am doing this:
>
>  HttpCli1.Url := 'http://www.whatismyip.com/automation/n09230945.asp';
>  HttpCli1.GetAsync;
>
> This returns with the RequestDone event, an ErrorCode of 0 and the correct
> RqType, but now what?
>
> Graham
>
> -Original Message-
> From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
> Behalf Of Angus Robertson - Magenta Systems Ltd
> Sent: 13 September 2010 14:39
> To: twsocket@elists.org
> Subject: Re: [twsocket] ICS - What Is My IP
>
> > Is there an ICS example somewhere?
>
> There are dozens of example ICS programs, and several that demonstrate
> various aspects of the HTTP client component, accessing a simple web page
> is
> about as easy as it gets.
>
> Angus
>
> --
> 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
>
--
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


Re: [twsocket] ICS - What Is My IP

2010-09-13 Thread Francois PIETTE
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


Re: [twsocket] ICS - What Is My IP

2010-09-13 Thread Graham Powell
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


Re: [twsocket] ICS - What Is My IP

2010-09-13 Thread Fredrik Larsson
http://wiki.overbyte.be/wiki/index.php/THttpCli.Get

If you need it sync (blocking) in the same way Indy does it.

Regards, Fredrik.

-Original Message-
From: twsocket-boun...@elists.org [mailto:twsocket-boun...@elists.org] On
Behalf Of Francois PIETTE
Sent: den 13 september 2010 17: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?

--
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


Re: [twsocket] ICS - What Is My IP

2010-09-13 Thread Arno Garrels
Graham Powell wrote:
> 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?

They obviously try to detect whether the request comes from a 
browser or a script, try to set the headers like Firefox and see
what happens or maybe you have to handle cookies as well?

Much better is to use your own webpage that returns the IP,
it's rock science, in PHP it looks like:

 

-- 
Arno Garrels


--
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


Re: [twsocket] ICS - What Is My IP

2010-09-13 Thread Francois PIETTE

This returns a message from whatismyip.com saying that I have been banned
for 5 minutes for hitting the site too often.

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


I would say: look at the user agent (Agent property). This is what a website 
use to see which program is connecting.
Or maybe the url you gave is somehow tied to your old program. Where does 
that URL comes from ?


--
francois.pie...@overbyte.be
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


Re: [twsocket] ICS - What Is My IP

2010-09-14 Thread Graham Powell
Changed the "Agent" to some random word and now it's all working fine.

Many thanks for all your help.

And in answer to someone else. I wanted to use ICS because it's inherently
asynchronous.

Graham

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

> This returns a message from whatismyip.com saying that I have been 
> banned for 5 minutes for hitting the site too often.
>
> Is there something else I should set to prevent this response?

I would say: look at the user agent (Agent property). This is what a website
use to see which program is connecting.
Or maybe the url you gave is somehow tied to your old program. Where does
that URL comes from ?

--
francois.pie...@overbyte.be
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