检查服务是否在外部UDP端口后运行

I'd like to check if a service is running behind a UDP port on an external machine.

The idea is that a user would be able visit a webpage and get an indication that they have correctly opened port 9999 in their router.

The service they are running is using UDP port 9999.

At the moment I have this.

<?php
$ip = '123.456.789.000';
$address = "udp://".$ip;

if(fsockopen($address, 9999))
{
print "Port 9999 is Open!";
}
else
{
print "Port 9999 is Closed!";
}
?>

The above is simple and works great for a TCP port. But the issue I'm having is that it always shows the port as open when using UDP.

Any pointers would be appreciated.

I have looked at How to check UDP port listen or not in php? but that only works internally (ie I can't bind the port) AFAIK?

I need to check the port is open on an external machine.

I have also looked at lots of others trying to piece something together but haven't managed it yet.

douying4203
douying4203 可能重复的如何在php中检查UDP端口是否侦听?
接近 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐