gpt4 book ai didi

PHP socket fread 响应需要永远

转载 作者:可可西里 更新时间:2023-11-01 02:50:34 26 4
gpt4 key购买 nike

我想通过 EPP 协议(protocol)向注册商发送 XML 请求并获得响应,连接成功,但是当我到达 fread($fp) 时,它需要很长时间才能加载。

有没有办法让它更快并得到注册商的回应?

我在 hostbill 插件中使用下面的代码。

 /** open socket* */
$fp = fsockopen("tcp://registrarwebsite.com", 700, $errno, $errstr, 200);

stream_set_blocking($fp, true);

stream_context_set_option($fp, 'ssl', 'verify_host', true);
stream_context_set_option($fp, 'ssl', 'verify_peer', true);
stream_context_set_option($fp, 'ssl', 'allow_self_signed', false);
stream_context_set_option($fp, 'ssl', 'local_cert', __DIR__ . '/ma_cert.pem');
stream_context_set_option($fp, 'ssl', 'local_pk', __DIR__ . '/ma_key.pem');


// $secure = stream_socket_enable_crypto($fp, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
// stream_set_blocking($fp, false);

if (!$fp) {
$this->addError('Il y a une erreur dans la connexion: ' . $errno . ' ' . $errstr);
return false;
} else {

$xml = htmlentities($this->prepareXMLRequest($xml));

fwrite($fp, $xml);

$out = fread($fp, 1024);

fclose($fp);

$out1 = htmlentities($fp);

$this->addError('<span style="color: green !important">Connexion se fait avec succes, le code retourné est : </span> ' . $out1);

最佳答案

你的 EPP 实现是错误的(如果服务器支持标准,当然),参见 RFC5734我引用:

  1. Data Unit Format

The EPP data unit contains two fields: a 32-bit header that describesthe total length of the data unit, and the EPP XML instance. Thelength of the EPP XML instance is determined by subtracting fouroctets from the total length of the data unit. A receiver mustsuccessfully read that many octets to retrieve the complete EPP XMLinstance before processing the EPP message.

另请注意第 3 节,当您打开 TCP/TLS 连接时,第一方发言的是服务器 <greeting>因此,作为客户,您首先需要阅读该内容,然后发送您的登录信息。

关于PHP socket fread 响应需要永远,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45331643/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com