[Lazarus] Detecting if a remote web server is running

2014-10-30 Thread Richard Mace
Hi All,
What's the most reliable way of detecting whether a remote website is
responding?

Thanks

Richard
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Detecting if a remote web server is running

2014-10-30 Thread Felipe Monteiro de Carvalho
maybe ping?

On Thu, Oct 30, 2014 at 10:44 AM, Richard Mace richard.m...@gmail.com wrote:
 Hi All,
 What's the most reliable way of detecting whether a remote website is
 responding?

 Thanks

 Richard

 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus




-- 
Felipe Monteiro de Carvalho

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Detecting if a remote web server is running

2014-10-30 Thread silvioprog
On Thu, Oct 30, 2014 at 6:44 AM, Richard Mace richard.m...@gmail.com
wrote:

 Hi All,
 What's the most reliable way of detecting whether a remote website is
 responding?


Get the HTTP headers:

uses
  fphttpclient;

procedure TForm1.Button1Click(Sender: TObject);
var
  VHttp: TFPHTTPClient;
  VHeaders: TStrings;
begin
  VHttp := TFPHTTPClient.Create(nil);
  VHeaders := TStringList.Create;
  try
VHttp.RequestHeaders.Add('Connection: Close');
VHttp.Head('http://lazarus.freepascal.org', VHeaders);
if VHeaders.Count  0 then
  ShowMessage('OK')
else
  ShowMessage('Fail');
  finally
VHeaders.Free;
VHttp.Free;
  end;
end;

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Detecting if a remote web server is running

2014-10-30 Thread Tony Whyman
Richard,

There is no substitute for suck it and see. I have a web server that I
need to ensure keeps running. I monitor it from another system that runs
a CRON job every five minutes that uses wget to download the home
page. If this fails it EMails me.

As you are putting this on the lazarus list. I assume that you want to
do something similar from an interactive Pascal program. Here there is
no substitute for good error handling. My experience is with the indy
components and these will raise an exception if they can't download a
given webpage (timeout). You can catch this and give the user an
appropriate error message when they try to access a non-responding
server. You could even have a background thread to keep doing this, if
it is really important to tell the user as soon as possible.

Tony Whyman
MWA

On 30/10/14 09:44, Richard Mace wrote:
 Hi All,
 What's the most reliable way of detecting whether a remote website is
 responding?

 Thanks

 Richard


 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Detecting if a remote web server is running

2014-10-30 Thread Mattias Gaertner
On Thu, 30 Oct 2014 12:29:00 +0100
Felipe Monteiro de Carvalho felipemonteiro.carva...@gmail.com wrote:

 maybe ping?

Many servers do not respond to ping. So not reliable.

Mattias

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Detecting if a remote web server is running

2014-10-30 Thread waldo kitty

On 10/30/2014 7:29 AM, Felipe Monteiro de Carvalho wrote:

On Thu, Oct 30, 2014 at 10:44 AM, Richard Mace richard.m...@gmail.com wrote:

Hi All,
What's the most reliable way of detecting whether a remote website is
responding?


 maybe ping?

ping might tell you if the IP address is active but that's all... it won't tell 
you if the server is running or servicing requests... you have to request 
something from the server to see if it is servicing requests... the easiest and 
smallest would be to request the headers (only) from the root...


--
 NOTE: No off-list assistance is given without prior approval.
   Please *keep mailing list traffic on the list* unless
   private contact is specifically requested and granted.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Detecting if a remote web server is running

2014-10-30 Thread silvioprog
On Thu, Oct 30, 2014 at 11:39 AM, waldo kitty wkitt...@windstream.net
wrote:

 On 10/30/2014 7:29 AM, Felipe Monteiro de Carvalho wrote:

 On Thu, Oct 30, 2014 at 10:44 AM, Richard Mace richard.m...@gmail.com
 wrote:

 Hi All,
 What's the most reliable way of detecting whether a remote website is
 responding?

 
  maybe ping?

 ping might tell you if the IP address is active but that's all... it won't
 tell you if the server is running or servicing requests... you have to
 request something from the server to see if it is servicing requests... the
 easiest and smallest would be to request the headers (only) from the root...


+1

Like this:
http://lists.lazarus.freepascal.org/pipermail/lazarus/2014-October/089112.html

-- 
Silvio Clécio
My public projects - github.com/silvioprog
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Detecting if a remote web server is running

2014-10-30 Thread Richard Mace
Thanks for everyone's replies, very helpful.

Richard

On 30 October 2014 14:42, silvioprog silviop...@gmail.com wrote:

 On Thu, Oct 30, 2014 at 11:39 AM, waldo kitty wkitt...@windstream.net
 wrote:

 On 10/30/2014 7:29 AM, Felipe Monteiro de Carvalho wrote:

 On Thu, Oct 30, 2014 at 10:44 AM, Richard Mace richard.m...@gmail.com
 wrote:

 Hi All,
 What's the most reliable way of detecting whether a remote website is
 responding?

 
  maybe ping?

 ping might tell you if the IP address is active but that's all... it
 won't tell you if the server is running or servicing requests... you have
 to request something from the server to see if it is servicing requests...
 the easiest and smallest would be to request the headers (only) from the
 root...


 +1

 Like this:
 http://lists.lazarus.freepascal.org/pipermail/lazarus/2014-October/089112.html

 --
 Silvio Clécio
 My public projects - github.com/silvioprog

 --
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus