ok, it's easy to code TCP port scanner by using socket but i don't know why it's hard to be the same for UDP
I just want to check if a specific UDP port (say port 500) is open or not.
Here is my code:
$ip = '103.12.9.209';
$port = '500';
$socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$result = socket_connect($socket, $ip, $port);
if ($result)
{
echo "Port is on";
}
else
{
echo "Port is off";
}
socket_close($socket);
The problem is it always return true (port is on) even it's off.
What is the problem? any idea please?
Thanks.