PHP multi-threaded and socket reliable unreliable or not good?

Source: Internet
Author: User
Tags php multithreading

Reply content:

Multithreading may not be reliable. PHP was not designed for multithreaded environments from the start, so the pthread extension would need to go deep into the PHP kernel and do very complex hack programming. Program A complex problem comes, there will certainly be a lot of bugs.

The socket is unreliable, look at people. The socket series function provided by PHP is the encapsulation of the operating system socket interface, very low level.

So for the socket function provided by PHP, if the developer is reliable, the naturally written program will be reliable. Developers who do not understand what is a socket, naturally written out of the program is not reliable.

You can learn about PHP's swoole extension, http://www. swoole.com/ PHP multithreading is generally used php:pthreads extension, I actually used this extension, the extension in the use of the process will have some problems, such as coredump, so it is not recommended to use

PHP socket use to no problem, the performance is good, after all, C is the simple package. And there's a lot of open source PHP sockets on GitHub.
For example:
Reactphp/react GitHub
Kakserpom/phpdaemon GitHub
Walkor/workerman GitHub
They are all based on PHP multi-process + PHP socket + Epoll and other multi-channel IO multiplexing
  • 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.