On Fri, Jun 3, 2011 at 2:20 AM, 李白|字一日 <calid...@gmail.com> wrote:

> is there an efficient way to hold the requests while loop is an expensive
> way in most cases.

You can call sleep(number_of_seconds_to_sleep) within the while loop to
lower the cost, so to speak.

> and i don't know how to notify the holding connections if the change need
> to be notify to the holding requests?

Sorry, I'm not sure what you mean here.

Let's say you were checking a db table for new rows. When a new row
appeared, you'd break out of the loop and return the data to the page with
the javascript that initiated the request (maybe you're PHP is returning
JSON, XML, or an HTML fragment for the javascript to manipulate.) The
javascript would update the page content and then initiate a new
long-polling request and wait for new data.

writing extension to php is also a very expensive way for me:(

I agree with you. That's in part why I suggested that the extension wouldn't
be needed or worthwhile in this case and basic PHP would be a reasonable

Nephtali:  A simple, flexible, fast, and security-focused PHP framework

Reply via email to