使用PHP进行SRV记录查找 [英] SRV record lookup with PHP

查看:174
本文介绍了使用PHP进行SRV记录查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您键入

nslookup -type=SRV _xmpp-server._tcp.gmail.com

(或在OSX中使用dig命令),您会收到一些与谷歌聊天有关的SRV记录

(or use the dig command in OSX) you get some SRV records relating to google chat

我想在PHP中复制此功能,有没有人有任何好的想法如何做到这一点?

I would like to replicate this functionality in PHP, does anyone have any good ideas how to do this?

我想避免使用exec ),因为这不会在OSX / * NIX / WINDOWS

I would like to avoid using exec() as this does not return 100% standard responses across OSX/*NIX/WINDOWS

中返回100%的标准响应谢谢!

Thanks!

推荐答案

您可以使用 Pear Net_DNS 。我设法让它在Linux上工作,但是还没有在Windows或其他任何方面进行测试:

You could use Pear Net_DNS. I managed to get this to work on Linux, but haven't tested it on Windows or any others:

require_once('Net/DNS.php');
$resolver = new Net_DNS_Resolver();
$response = $resolver->query('_xmpp-server._tcp.gmail.com', 'SRV');
if ($response) {
  foreach ($response->answer as $rr) {
    $rr->display();
  }
}

我从他们的文档中修改了示例。希望这有助于

I modified the example from their documentation. hope this helps

这篇关于使用PHP进行SRV记录查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆