Phpsocket data waiting, php stuck

Source: Internet
Author: User
When phpsocket data is waiting, php is stuck with a server program. Multithreading. Use php to connect through socket. The server sends and receives data synchronously. Thread pool.

The problem is. After I use php to connect to the server program. Wait for a while. Data can be returned.
At this time. Php cannot be parsed. The server program can process the socket request normally, but the entire php is stopped and must wait until the data is returned. After receiving data. To continue parsing the php file.

Is there any way to stop php from all the time and wait until the data is returned.


Reply to discussion (solution)

Since it is synchronous sending and receiving, of course we have to wait.

For web programs, ajax is used to asynchronously call the php socket program to prevent page termination.
For the CLI program, add the libevent extension of php or the pthreads extension of multithreading.

The current page is not stopped. But .. The entire php is stopped... Until the data is received .. Php can continue parsing.

Synchronization will certainly have to wait, unless you use asynchronous.

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.