How can I write efficient ping detection using PHP?

Source: Internet
Author: User
There are hundreds of IP addresses, that is, they want to discover that an IP address is disconnected in time. Then return the message. Xiao Cai, I just read some code on the Internet. I can use ping, socket, and curl to write the code. But do I think efficiency is not quite appropriate? Ask experienced friends for support. There are hundreds of IP addresses, that is, they want to discover that an IP address is disconnected in time.
Then return the message.
Xiao Cai, I just read a few codes on the Internet, which are written using ping, socket, and curl.
But do you think efficiency is not quite appropriate?
Ask experienced friends for support.

Reply content:

There are hundreds of IP addresses, that is, they want to discover that an IP address is disconnected in time.
Then return the message.
Xiao Cai, I just read a few codes on the Internet, which are written using ping, socket, and curl.
But do you think efficiency is not quite appropriate?
Ask experienced friends for support.

Use the system function in php to call the fping tool in linux, so that you can ping the tool in batches. (Fping can send a large number of ping requests in parallel in rotation mode)
Should you write such simple code?

Use tools instead of making wheels on your own

You should try the asynchronous library, so the time spent will be the longest delay in ping, rather than all the accumulation of ping time. PHP has swoole, which is located in timeout.

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.