Link to home
Start Free TrialLog in
Avatar of ccsking
ccsking

asked on

HOw to check proxy in delphi

Hello experts,

i need fast method that could check http proxy server status.
somth like this:

function check(proxy : string, port : word) : boolean;

returns true if proxy is working.

Thanks.


Avatar of Evarest
Evarest

This code should do the trick:

NOTE: it requires INDY components to be installed. You can download these excellent components for free from

http://www.indyproject.org/download/Borland.html

[BEGIN CODE]

uses
  IdHTTP;

function check(proxy : string; port : word) : boolean;
var
 IdHTTP: TIdHTTP;
begin
 result :=false;
 with TIdHTTP.Create(nil) do
  begin
   ProxyParams.ProxyServer :=proxy;
   ProxyParams.ProxyPort :=Port;
   try
    Get('http://www.google.com');
    result :=true;
   except
   end;
   Free;
  end;
end;

[END CODE]

I check for http://www.google.com as this site is online for the most time :-)

Hope to help...
Evarest
Avatar of ccsking

ASKER

it is good method but not fast becouse it needs to download data from webpage.
i think it should be the faster way to check proxy
am i right?
Avatar of ccsking

ASKER

and another thing: method "get" is not very good if you want to check several proxies at same time
ASKER CERTIFIED SOLUTION
Avatar of Pierre Cornelius
Pierre Cornelius
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial