PHP multithreading and socket are reliable and unreliable, OK?

Source: Internet
Author: User
Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming... Reply content: multithreading may be unreliable. PHP was not designed for a multi-threaded environment from the very beginning, so the extension of pthread needs to go deep into the PHP kernel and perform very complex Hack programming. A complicated program problem arises, and there will certainly be many bugs.

The Socket is reliable and unreliable. The socket functions provided by PHP are all encapsulation of the socket interface of the operating system, which is very underlying.

Therefore, for the socket functions provided by PHP, if developers are reliable, the naturally written programs will be reliable. If developers do not understand socket at all, the naturally written programs are unreliable.

You can take a look at the swoole extension, http://www.swoole.com/ Php multithreading generally uses PHP: pthreads I have actually used this extension. this extension has some problems during use, such as coredump, so it is not recommended to use it.

Php socket has no problem, and the performance is good. after all, it is a simple encapsulation of c. There are many open-source php socket projects on github.
For example:
Reactphp/react · GitHub
Kakserpom/phpdaemon · GitHub
Author or/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.