PHP + Sockets, Real time look and feel?
Posted: Fri Mar 04, 2005 1:25 pm
Well, I'm trying to develop a certain area on my website in such a way that you don't need to refresh the page, and clicking links etc don't refresh the page. PHP being preprocessor server-side language I'm wondering if that's even possible. I've been reading about sockets, and was testing use with TCP port 80. Yeah sure I can open a socket send some info to my page and close it. But is it possible to keep the socket open and run php functions from that page without refreshing it?
Here's an example of what I mean. I have a page lets call it realtime.php,
inside I have a bunch of functions I want to use. The entire php script is wrapped in a while loop, which listens for TCP input on port 80. The page has a div with id "myDiv". Every time the user sends some input, it changes the innerHtml of "myDiv" based on the input from the user. (runs a different function for different input and changes innerHtml)
Is this possible? Or because PHP is a preprocessor server-side language will my page not load at all and be in an infinite loop waiting for input it will never receive?
Are there any other options to get this kind of real time feel in a php/mysql page?
Here's an example of what I mean. I have a page lets call it realtime.php,
inside I have a bunch of functions I want to use. The entire php script is wrapped in a while loop, which listens for TCP input on port 80. The page has a div with id "myDiv". Every time the user sends some input, it changes the innerHtml of "myDiv" based on the input from the user. (runs a different function for different input and changes innerHtml)
Is this possible? Or because PHP is a preprocessor server-side language will my page not load at all and be in an infinite loop waiting for input it will never receive?
Are there any other options to get this kind of real time feel in a php/mysql page?