Log In    |    Knowledge Base    |    4D Home
Tech Tip: Checking if Host Is Reachable Using NET_Ping.
PRODUCT: 4D Internet Commands | VERSION: 2003 | PLATFORM: Mac & Win
Published On: September 2, 2004

You can use the NET_Ping command of the Internet Command Plug-in to check if a system with a given IP Address or hostname is active and accessible. A system that is currently active and that is connected to the network and using TCP/IP protocol should respond to the NET_Ping command provided. If the machine has a firewall enforced, the firewall can prevent it from replying. The NET_Ping command uses up to four parameters: NET_Ping(hostname;text;alive{;timeout}). It returns an error_code and passes the status of the system on the alive parameter. The text parameter only affects the size of the packet sent with the ping command. Below is sample method that will display if an IP address or host name is reachable.

 `Method: Ping
$errcode:=NET_Ping ($1;"test";$alive)
If ($errcode=0)
  If ($alive#1)
       ALERT($1+" is not active.")
      ALERT($1+" is active.")
  End if
  ALERT("Error # "+String($errcode)+" occurred")
End if