我连接到了whois服务器,并且能够检索域名的可用性。不知何故,当我请求不同的域名时,我无法使用相同的连接返回响应。
<?php
$context = stream_context_create();
if($fp = stream_socket_client("tcp://whois.eu:43", $errno, $errstr, 30, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $context)) {
stream_set_timeout($fp, 30);
$domains = array('test.eu','amaai.eu');
foreach($domains as $domain) {
fwrite($fp, $domain."\r\n");
$contents = '';
while (!feof($fp)) {
$contents .= fread($fp, 8192);
}
echo $domain.": ".$contents;
}
fclose($fp);
}我遗漏了什么?我真的想使用相同的连接。
发布于 2020-06-26 22:55:52
WHOIS协议只支持一个查询。服务器在发送响应后关闭连接。您需要为每个查询重新连接。
https://stackoverflow.com/questions/62596435
复制相似问题