User Tools

Site Tools


uphp:functions:ping

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
uphp:functions:ping [2017/05/13 11:45]
admin created
uphp:functions:ping [2021/09/13 05:57] (current)
Line 1: Line 1:
-array ping(string $host)+======ping======
  
-Sends an ICMP ping request to a host name (resolved via DNS) or an IP address and returns status as an array+<badge>WMPRO, WMMINI FW >= 1.0</badge> <badge>WMMEGA FW >= 2.0</badge> 
 + 
 +Send an ICMP ping and place the result in an <html><b><span style="color:green">array<span style="color:black"></b></html> 
 + 
 +====Description==== 
 + 
 +<well size="sm"><html> 
 +<span style="font-size:125%;color:green">array 
 +<span style="color:black">ping ( 
 +<span style="color:green">string 
 +<span style="color:blue">$host 
 +<span style="color:black">
 +</html></well> 
 + 
 +<html>This function sends an ICMP ping request to a <b><span style="color:blue">host<span style="color:black"></b> by name or IP address and returns connection information as an <b><span style="color:green">array<span style="color:black"></b>.</html> 
 + 
 +====Parameter==== 
 + 
 +<html><b><span style="color:blue">$host<span style="color:black"></b></html>:  A URI web address name (such as example.com) or an IP address (such as 172.16.254.1). If a URI is provided the function will attempt to resolve it to an IP address by DNS. 
 + 
 +====Return Values==== 
 + 
 +A key/value <html><b><span style="color:green">array<span style="color:black"></b></html> of connection status information: 
 + 
 +^Key^Type^Description^ 
 +|response|<html><b><span style="color:green">int<span style="color:black"></b></html>|1 if connection was successful, -1 if failure| 
 +|time|<html><b><span style="color:green">int<span style="color:black"></b></html>|Response time in ms| 
 +|host|<html><b><span style="color:green">string<span style="color:black"></b></html>|Host name or IP address as passed to the function| 
 +|ip|<html><b><span style="color:green">string<span style="color:black"></b></html>|IP Address that DNS returned for the host| 
 +|seq|<html><b><span style="color:green">int<span style="color:black"></b></html>|Incremental sequence number for ping| 
 + 
 +====Example==== 
 + 
 +<code php> 
 +<? 
 +  $res=ping("example.com"); 
 +?> 
 +</code>
  
 Sample result if no connection is established: Sample result if no connection is established:
 +<code>
 [$res] = Array ( [$res] = Array (
 (int) [response] => -1 (int) [response] => -1
-(string) [host] => google.com+(string) [host] => example.com
 (string) [ip] => 0.0.0.0 (string) [ip] => 0.0.0.0
 (int) [seq] => 0 (int) [seq] => 0
  
 +</code>
  
-Result when successful: +Sample result if a connection is successful: 
 +<code>
 [$res] = Array ( [$res] = Array (
 (int) [response] => 1 (int) [response] => 1
 (int) [time] => 25 (int) [time] => 25
-(string) [host] => google.com +(string) [host] => example.com 
-(string) [ip] => 216.58.196.110+(string) [ip] => 93.184.216.34
 (int) [seq] => 2 (int) [seq] => 2
  
 +</code>
 +
 +====See Also====
  
-Result array fields: +[[fsockopen()]] - Open an internet socket connection with optional timeout
-|field|type|description| +
-|response|int|-1 if failed, or else 1| +
-|time|int|response time in ms| +
-|host|string|host name (passed to the call)+
-|ip|string|IP Address that DNS returned for the host| +
-|seq|int|incremental sequence number for ping|+
  
uphp/functions/ping.1494675945.txt.gz · Last modified: 2021/09/13 05:56 (external edit)