Question on browser php file loading mechanics
Posted: Wed Nov 26, 2014 12:53 pm
Hi,
For instance, when exploring the Socket Server and Socket Client examples I found a php.net manual, I was puzzled about how the browser behaves when there is an infinite loop (or while) running.
When the infinite loop or do while is active, the Client socket page doesn't fully load on the browser, and that's because it process has not finished completing, and since browsers read web files from top to bottom, if it is stuck in the middle, then the page does not load at all.
But I found a way to keep it simple, now I have come up with a way to let the Server socket remain running (of course, that's why it is called a server). But I noticed that when I was trying to implement the concept of sending a packet of information (or as I would name it, a token), I don't require to keep the client socket running in a loop (sort of speak, to keep the connection going) because all I need is for the client to send information and the server responding accordingly. How it responds of course is according to what the token contains. So while using the Server socket which accepts the multiple client connections, I was getting "socket_read() failed..." messages everytime the a client page that I had start would close, or when I would send the "quit" command to close the connection between the server and client...the reason I was getting the socket_read() fail error is because of just that, I rewrote or twitched it a little to suite my needs, so that when the client sends its token, it would also close the socket connection so that the page would not stay on the loading instance. So that was not working well because at the other end, the server side, I was using Multi-socket connection algorithm.
To avoid all that hassle, I went instead with the single Server Socket connection along with the my version of the Client Socket connection (now it works beautifully). I can say, now I understand PHP sockets, at least for the basic part.
Now my question has to do with Concurrency or multithread or threads. Obviously, PHP does not work like Java, and that's the beauty of Java. But I am not writing Java anymore, so I want to know, is there a way to accomplish concurrency with PHP.
Or upon each instance that there is a change in the content, you do a refresh of the page? but wouldn't you get the flicker? wouldn't you be stuck on the reloading process? How can one make this work?
Thanks.
For instance, when exploring the Socket Server and Socket Client examples I found a php.net manual, I was puzzled about how the browser behaves when there is an infinite loop (or while) running.
When the infinite loop or do while is active, the Client socket page doesn't fully load on the browser, and that's because it process has not finished completing, and since browsers read web files from top to bottom, if it is stuck in the middle, then the page does not load at all.
But I found a way to keep it simple, now I have come up with a way to let the Server socket remain running (of course, that's why it is called a server). But I noticed that when I was trying to implement the concept of sending a packet of information (or as I would name it, a token), I don't require to keep the client socket running in a loop (sort of speak, to keep the connection going) because all I need is for the client to send information and the server responding accordingly. How it responds of course is according to what the token contains. So while using the Server socket which accepts the multiple client connections, I was getting "socket_read() failed..." messages everytime the a client page that I had start would close, or when I would send the "quit" command to close the connection between the server and client...the reason I was getting the socket_read() fail error is because of just that, I rewrote or twitched it a little to suite my needs, so that when the client sends its token, it would also close the socket connection so that the page would not stay on the loading instance. So that was not working well because at the other end, the server side, I was using Multi-socket connection algorithm.
To avoid all that hassle, I went instead with the single Server Socket connection along with the my version of the Client Socket connection (now it works beautifully). I can say, now I understand PHP sockets, at least for the basic part.
Now my question has to do with Concurrency or multithread or threads. Obviously, PHP does not work like Java, and that's the beauty of Java. But I am not writing Java anymore, so I want to know, is there a way to accomplish concurrency with PHP.
Or upon each instance that there is a change in the content, you do a refresh of the page? but wouldn't you get the flicker? wouldn't you be stuck on the reloading process? How can one make this work?
Thanks.