【问题标题】:Socket Error ******* - Unable to find the socket transport "http"套接字错误 ******* - 找不到套接字传输“http”
【发布时间】:2017-06-23 00:14:35
【问题描述】:

当我尝试查找域注册商详细信息时,我收到错误“套接字错误 ******* - 无法找到套接字传输“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数据库以获取域注册信息。

【问题讨论】:

    标签: php sockets


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      谢谢, 维杰

      【讨论】:

        猜你喜欢
        • 2012-04-15
        • 1970-01-01
        • 2013-05-14
        • 2020-02-11
        • 2018-09-17
        • 1970-01-01
        • 2016-06-28
        • 1970-01-01
        • 2017-06-10
        相关资源
        最近更新 更多