查询DHT服务器 [英] Query DHT Server

查看:171
本文介绍了查询DHT服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对DHT服务器进行简单的查询.

I'm trying to make a simple query to a DHT server.

我正在尝试制作一个简单的示例来测试对服务器的查询,但是我没有从服务器获得任何形式的响应...

I'm trying to make a simple simple example to test queries to the servers, but I don't get a response from the server in any form...

小例子:

$socket = fsockopen("udp://router.bittorrent.com", 6881, $errno, $errstr, 3);
fwrite($socket, 'p'); $Head = fread($socket, 4);
$CheckStatus = socket_get_status($socket);      
if($CheckStatus["unread_bytes"] == 0)
{
    return 0;
}   
$do = 1;
while($do)
{
    $str = fread($socket,1);
    $stats .= $str;
    $status = socket_get_status($socket);
    if($status["unread_bytes"] == 0)
    {
        $do = 0;
    }
}
fclose($socket);

有关DHT服务器中查询的信息,请点击此处: http://www .bittorrent.org/beps/bep_0005.html#dht-queries

The info about the queries in DHT server is here: http://www.bittorrent.org/beps/bep_0005.html#dht-queries

但是我不明白如何用PHP做到这一点. 这可能吗?我的代码有什么问题?

But I don't understand how make this with PHP. Is this possible? What's the problem with my code?

推荐答案

如8472所述,您的客户端正在发送p,这不是有效的查询.要查看有效的查询格式,请点击此处: bep 005

As the8472 mentions, your client is sending p, which is not a valid query. To see valid query formats, look here: bep 005

这篇关于查询DHT服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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