Php cyclically requests multiple URLs

Source: Internet
Author: User
Php cyclically requests multiple URLs to the current network segment (192.168.1.0 ~ 192.168.1.255), request url, and send data.
The url must be executed cyclically. the returned results do not need to be processed, and the returned results are not waiting.
How can this function be implemented ?.


Reply to discussion (solution)

 

PHP code? 1234567
Thank you for your reply. The socket only opens the link. This url is not executed, right? How can I execute this url?

$ StreamData = "GET {$ url} HTTP/1.0 \ r \ n"; $ streamData. = "Accept: */* \ r \ n"; $ streamData. = "Accept-Language: zh-cn \ r \ n"; $ streamData. = "Host: {$ host} \ r \ n"; $ streamData. = "Connection: Close \ r \ n"; $ streamData. = "Cookie: \ r \ n"; $ ip = ""; $ timeout = 15; $ fp = fsockopen ($ ip? $ Ip: $ host), $ port, $ errno, $ errstr, $ timeout); $ ret = ""; if (! $ Fp) {return '$ errstr: $ errno'; // note $ errstr: $ errno \ r \ n} else {// Set blocking/non-blocking mode stream, $ block = true applies the stream mode stream_set_blocking ($ fp, false); // sets the stream timeout Time // stream_set_timeout ($ fp, $ timeout); fputs ($ fp, $ streamData); // while (! Feof ($ fp) {// $ ret. = fgets ($ fp, 128); //} fclose ($ fp); // echo $ ret ;}

Fopen ("http: // 127.0.0.1: 8182/now/form. php? Id = 5689 "," r ");
File_get_contents ("http: // 127.0.0.1: 8182/now/form. php? (Id = 5689 ");
Run the specified url. both methods run successfully on apache.
Failed in ngiux. Ask Why

Php. ini is required for file functions to act on URLs.
Allow_url_fopen = On

Allow_url_fopen = On // enabled

Test. php
Echo file_get_contents ("http: // localhost: 8182/now/form. php ");
?>
Form. php
Echo "abc ";
?>
-------------------------
The same code is executed differently in apache and nginx.
Run test. php:
Apache output: abc; nginx running error, the page is always refreshed

Php. ini is required for file functions to act on URLs.
The same allow_url_fopen = On code is executed differently in apache and nginx. Thank you.

May be nginx configuration problems? Not clear

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.