PHP implements asynchronous processing

resource fsockopen ( string $hostname [, int $port = -1 [, int &$errno [, string &$errstr [, float $timeout = ini_get("default_socket_timeout") ]]]] )

parameter

 

hostname

If OpenSSL is installed , then you should probably add the access protocol ssl:// or tls:// to the front of your hostname address so that clients can connect to remote hosts using SSL or TLS over TCP/IP.

port

The port number. If you pass a -1 to this parameter, it means that the port is not used, such as unix:// .

errno

If this parameter is passed, holds the system level error number that occurred in the system-level connect() call.

If errnothe return value is 0 , and the return value of this function is 0 FALSE, then this indicates that the error occurred before the socket connect ( connect() ) call, and the most likely cause of the connection failure is when the socket is initialized. error.

errstr

Error messages will be returned as strings.

timeout

Set the connection time limit, in seconds. 

 

lg: ww.php

$fp = fsockopen($_SERVER['HOST'],80);
if(!$fp){

}else{
    $param = array(
        'name' => 'fdipzone',
        'gender' => 'man',
        'photo' => file_get_contents('photo.jpg')
    );

    $data = http_build_query($param);
    $out = "POST /api/im-wa/new HTTP/1.1\r\n"; //Simulate POST request
    $out .= "Host: www.example.com\r\n";
    $out .= "Content-Type: application/x-www-form-urlencoded\r\n";//POST数据
    $out .= "Content-Length: ". strlen($data) ."\r\n";//Length of POST data
    $out.="Connection: Close\r\n\r\n";//Long connection close
    $out .= $data; //pass POST data
    stream_set_blocking($fp,true);
    stream_set_timeout($fp,1);
    fwrite($fp, $out);
    usleep(1000);
    fclose($fp);
}

  wa.php

file_put_contents('1.txt',json_encode($_POST));

  

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325847153&siteId=291194637