套接字错误******* - 无法找到套接字传输" http"

时间:2017-02-06 06:05:29

标签: php sockets

当我尝试查找域名注册商详细信息时,我收到错误"套接字错误******* - 无法找到套接字传输" http" - 您是否忘记启用它配置PHP时?"

public function whoislookup($domain){
$domain = trim($domain); //remove space from start and end of domain
if(substr(strtolower($domain), 0, 7) == "http://") $domain = substr($domain, 7); // remove http:// if included
if(substr(strtolower($domain), 0, 4) == "www.") $domain = substr($domain, 4);//remove www from domain
if(preg_match("/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/",$domain))
    return $this->queryWhois("whois.lacnic.net",$domain);
elseif(preg_match("/^([-a-z0-9]{2,100})\.([a-z\.]{2,8})$/i",$domain))
{
    $domain_parts = explode(".", $domain);
    $tld = strtolower(array_pop($domain_parts));
    $server = $this->WHOIS_SERVERS[$tld][0];
    if(!$server) {
        return "Error: No appropriate Whois server found for $domain domain!";
    }
    $res=$this->queryWhois($server,$domain);
        while(preg_match_all("/Whois Server: (.*)/", $res, $matches))
        {
            $server=array_pop($matches[1]);
            $res=$this->queryWhois($server,$domain);
        }
    return $res;
}
else
return "Invalid Input";}

private function queryWhois($server,$domain)
{
    $fp = @fsockopen($server, 43, $errno, $errstr, 20) or die("Socket Error " . $errno . " - " . $errstr);
    if($server=="whois.verisign-grs.com")
        $domain="=".$domain;
        fputs($fp, $domain . "\r\n");
        $out = "";
        while(!feof($fp)){
            $out .= fgets($fp);
        }
    fclose($fp);
    return $out;
}

我从不同的功能获取域名。在此功能中使用该域名,并搜索whois数据库以获取域注册信息。

2 个答案:

答案 0 :(得分:0)

刚才我发现查找不仅仅适用于“ES”,而且需要一个没有列入黑名单的IP。 Limitations mentioned here

答案 1 :(得分:0)

如何使用套接字方法加速上述代码的数据传输。

谢谢, 维杰