Implementation of php Asynchronous processing

Baidu comes out, it feels good to use fsockopen to achieve asynchronism, it is not actually used in the generation environment, I do not know if there is a pit?
are there any other good solutions?

<?php
 
$url = "http://www.example.com/doRequest.php";
$param = array(
    "name"=>"fdipzone",
    "gender"=>"male",
    "age"=>30
);
 
doRequest($url, $param);
 
function doRequest($url, $param=array()){
 
    $urlinfo = parse_url($url);
 
    $host = $urlinfo["host"];
    $path = $urlinfo["path"];
    $query = isset($param)? http_build_query($param) : "";
 
    $port = 80;
    $errno = 0;
    $errstr = "";
    $timeout = 10;
 
    $fp = fsockopen($host, $port, $errno, $errstr, $timeout);
 
    $out = "POST ".$path." HTTP/1.1\r\n";
    $out .= "host:".$host."\r\n";
    $out .= "content-length:".strlen($query)."\r\n";
    $out .= "content-type:application/x-www-form-urlencoded\r\n";
    $out .= "connection:close\r\n\r\n";
    $out .= $query;
 
    fputs($fp, $out);
    fclose($fp);
}
 
?>
Php
Jun.29,2021

fsockopen is a socket connection, right? Does it have anything to do with asynchrony? What are your requirements


Asynchronous processing mostly uses message queues, which is a socket connection and has little to do with asynchrony


can be regarded as asynchronous, and curl requests are of this type, asynchronous and non-blocking.

if it is a message queue, it is recommended that the redis, read and write speed is very fast. If the amount of data is relatively large, for example, the speed of entering the queue is very slow when it exceeds 10kr Redis.


PHP if you have friends who want to learn and communicate, you can add a group of 646724664

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ead055-46e63.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ead055-46e63.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?