Results 1 to 6 of 6
Thread: [PHP] Ping a UDP Port?
-
10-27-2007, 11:00 PM #1WHT Addict
- Join Date
- Jan 2007
- Location
- Bay Area, CA
- Posts
- 143
[PHP] Ping a UDP Port?
[PHP] Ping a UDP Port?
Hey guys, I'm working on a site that needs to ping and see if a UDP port is up. I know you can use TCP ports with php but how to do with UDP?
Thanks!
-
10-28-2007, 12:18 AM #2Web Hosting Master
- Join Date
- Apr 2005
- Posts
- 1,767
-
10-28-2007, 11:18 AM #3Web Hosting Master
- Join Date
- Jul 2003
- Location
- Kuwait
- Posts
- 5,104
You can't ping a UDP port.
-
10-29-2007, 05:28 PM #4Junior Guru
- Join Date
- Mar 2006
- Posts
- 221
Quicker (from php.net):
PHP Code:<?php
$fp = fsockopen("udp://127.0.0.1", 13, $errno, $errstr);
if (!$fp) {
echo "ERROR: $errno - $errstr<br />\n";
} else {
fwrite($fp, "\n");
echo fread($fp, 26);
fclose($fp);
}
?>
-
10-30-2007, 03:36 AM #5Disabled
- Join Date
- Aug 2007
- Posts
- 292
-
10-30-2007, 06:14 PM #6
Why ping? Ping doesn't tell you if it's giving the proper response, nor does it tell you much of anything except "port is up".
As others have suggested, use fsockopen, analyze the response, and go from there.Tom Whiting, WHMCS Guru extraordinaire
Linux problems? WHMCS Problems? Give me a shout
Check out my WHMCS Addons