Page 1 of 1

check udp socket

Posted: Fri Apr 21, 2006 9:12 am
by blacksun
I want to check if SNMP on (port 161) is running on a remote host.

SNMP uses UDP and I know that you should send data to UDP in order to know if the the service is
running

Consider the code :

Code: Select all

/*Check UPD protocol : services NTP , NFS, SNMP*/
function checkPortUDP($host,$port,$timeout = 2){
    $fp = @fsockopen("udp://".$host, $port, $errno, $errstr, $timeout);
	    if (!$fp) return false;
		else return false;
}//end function
How do I check if SNMP is running?

Posted: Fri Apr 21, 2006 9:13 am
by feyd
Help with what?

Posted: Fri Apr 21, 2006 9:22 am
by blacksun
how do i check if the udp port is running snmpd?

Posted: Fri Apr 21, 2006 9:28 am
by timvw
talk some snmp to it? :p (Btw, there is an snmp extension)

Posted: Fri Apr 21, 2006 9:31 am
by blacksun
i already have that in my application; before I talk SNMP;
i want to check the UDP ports for (SNMP, NTP etc).

how do i check if the UDP port is up?

Posted: Fri Apr 21, 2006 9:35 am
by feyd
You have to talk SNMP to it. There's no way around that as the socket may open without knowing if the connection failed or not.

Posted: Fri Apr 21, 2006 9:48 am
by blacksun
ok; i see.