This shows you the differences between two versions of the page.
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 | + | < |
+ | |||
+ | Send an ICMP ping and place the result in an < | ||
+ | |||
+ | ====Description==== | ||
+ | |||
+ | <well size=" | ||
+ | <span style=" | ||
+ | <span style=" | ||
+ | <span style=" | ||
+ | <span style=" | ||
+ | <span style=" | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | |||
+ | ====Parameter==== | ||
+ | |||
+ | < | ||
+ | |||
+ | ====Return Values==== | ||
+ | |||
+ | A key/value < | ||
+ | |||
+ | ^Key^Type^Description^ | ||
+ | |response|< | ||
+ | |time|< | ||
+ | |host|< | ||
+ | |ip|< | ||
+ | |seq|< | ||
+ | |||
+ | ====Example==== | ||
+ | |||
+ | <code php> | ||
+ | <? | ||
+ | $res=ping(" | ||
+ | ?> | ||
+ | </ | ||
Sample result if no connection is established: | Sample result if no connection is established: | ||
+ | < | ||
[$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 | ||
) | ) | ||
+ | </ | ||
- | Result when successful: | + | Sample result if a connection is successful: |
+ | < | ||
[$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 | ||
) | ) | ||
+ | </ | ||
+ | |||
+ | ====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| | + | |