duanjia7912 2018-11-17 00:36
浏览 108

检查服务是否在外部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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!
    • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
    • ¥15 求daily translation(DT)偏差订正方法的代码
    • ¥15 js调用html页面需要隐藏某个按钮
    • ¥15 ads仿真结果在圆图上是怎么读数的
    • ¥20 Cotex M3的调试和程序执行方式是什么样的?
    • ¥20 java项目连接sqlserver时报ssl相关错误
    • ¥15 一道python难题3