我正在尝试对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", 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服务器中查询的信息,请点击此处: www .bittorrent/beps/bep_0005.html#dht-queries
The info about the queries in DHT server is here: www.bittorrent/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服务器
发布评论