PHP implements asynchronous processing

Source: Internet
Author: User

Resource fsockopen ( string $hostname [, int $port =-1 [, int &$errno [, string &$errstr [, C16>float $timeout = Ini_get ("default_socket_timeout") ]]

Parameters

hostname

If OpenSSL is installed, then you should probably add the Access Protocol ssl:// or tls://to your host name address, so that you can connect to the remote host using TCP/IP protocol-based SSL or TLS.

port

Port number. If you pass a-1 to this parameter, you do not use a port, such as unix://.

errno

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

If errno the return value is 0, and the return value of this function FALSE is, then this indicates that the error occurred before the socket connection (Connect ()) call, The most likely cause of a connection failure is an error occurred while initializing the socket.

errstr

The error message is returned as a string of information.

timeout

Sets the time frame for the connection, in seconds. &NBSP,

 

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";    Analog POST request $out. = "host:www.example.com\r\n"; $out. = "content-type:application/x-www-form-urlencoded\r\n";//post data $out. = "Content-length:". Strlen ($data). " \ r \ n "; The length of the//post data $out. =" connection:close\r\n\r\n ";//long connection close $out. = $data;    Pass the 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)); 

 

 

PHP implements asynchronous processing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.