Hi there,
I am setting up a socket server and all the examples I have seen use an infinite while(true) loop to keep the script alive and monitor for socket changes. There must be a better way as the loop alone uses 50% cpu with no connections.
Is there no async event handling with sockets or way to keep a
script (I know, script) alive without sleep()?
There is nothing out there unfortunately. PHP is strictly pre-processor, so once the page is idle and nothing else is being processed, you can't use php. You might want to steer away from it anyway. I would write a C program / daemon and call it with exec from php. Then all you have to do is update the page every so often.
Bookmarks