The fsockopen php operation failed because of a server setting problem and localhost was not monitored. The solution is to reset the server network environment.
The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer
Specific questions:
php fsockopen local error? How to solve the problem of fsockopen php operation failure?
An error occurred when using fsockopen to make an asynchronous call. The same code did not cause problems under Alibaba Cloud centos and Tencent Cloud win2008.
Write the host address to 127.0.0.1 or localhost appears:
Warning: fsockopen(): Unable to connect because the target machine actively refuses. (10061)
host writes the current server domain name and appears:
Warning: fsockopen(): The connection attempt failed because the connecting party did not reply correctly after a period of time or the connected host did not respond. (10060)
host address The current server internal network IP is such as 192.168.3.3. The response is normal and there is no error.
Moreover, there is no problem when the server fsockopens to other servers or when other servers want to fsockopen the server and can be sent normally.
The code is as follows:
function async_post($host,$path,$data){ $post = http_build_query($data); $len = strlen($post); $fp = fsockopen( $host , 80, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)\n"; } else { $out = "POST $path HTTP/1.1\r\n"; $out .= "Host: $host\r\n"; $out .= "Content-type: application/x-www-form-urlencoded\r\n"; $out .= "Connection: Close\r\n"; $out .= "Content-Length: $len\r\n"; $out .= "\r\n"; $out .= $post."\r\n"; fwrite($fp, $out); fclose($fp); } }
is ultimately called through the intranet IP, but why is this?
Solution:
The source of the problem has been found:
Server setting problem, not listening to localhost
Server network environment, no I know which network administrator did it. The server cannot access itself through the external IP.
As a result, fsockopen can only be accessed through 192.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to solve the problem of fsockopen php operation failure. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
