WebPing Function

Action

Checks the availability of a specified host by sending an ICMP echo request (ping).

Include file

WebAPI.bdh

Syntax

WebPing( in sHost     : string,
         in nTimeout  : number optional,
         in nPings    : number optional,
         in nDataSize : number optional): boolean;

Return value

  • true if the host responds at least one time

  • false otherwise

Parameter Description
sHost Domain name or IP address, for example, hostname.com or 192.231.34.1
nTimeout Time, in ms, in which the tested host has to respond, otherwise it is considered to be not responding (optional). The default timeout is 1 second.
nPings Number of pings to be sent (optional). The default value is 3.
nDataSize Size of the additional data that the ICMP echo request sends (optional). This must be a value between 0 and 65527, inclusive. The default value is 32.

Example

dcltrans
transaction TMain
var
  nResult: number;
begin
  if not WebPing("lab1") then
    Print("host lab1 is not responding")
  else
    Print("host lab1 is alive")
  end;
  if not WebPing("192.168.100.101", 500, 1)  then
    Print("host 192.168.100.101 is not responding")
  else
    Print("host 192.168.100.101 is alive")
  end;
end TMain;