Page 1 of 1

Page doesn't load untill socket is completed

Posted: Wed Dec 20, 2006 12:02 pm
by Hassanur
I m working on Bandwidth Manger (to manage the bandwidth within lan) as my Final year project. I m using php but it seems that I must switch to java ....
Administrator PC will wait for http request .... The problem is that I establish socket connections ... then socket_listen waits for any type of request, & so hang other thing of web page. As I have to do this (listening the http port ) continously (endless loop), so none of the page contents will be displayed....

I need u guys opinion that should I switch to java or there is any solution ?? I will prefer the replies at "hassanrahman@yahoo.com"

Posted: Wed Dec 20, 2006 12:24 pm
by John Cartwright
You can output the results as you receive them with output buffering, although I don't think your approaching this from the right angle.

Personally, I would have a listener script like you have, which inserts information into another source which can be read, such as a database and using another page to view the results. To keep the data coming in live, you'll likely need to use AJAX, unless you don't mind page refreshes.

Posted: Wed Dec 20, 2006 12:48 pm
by printf
You can use non-blocking on both the connection and the stream and then you don't have to wait on anything, so you can do other stuff and read from the stream when there is data waiting to be processed. Most people think PHP can not handle multi processes without forking, but that is not true, because PHP can handle hundreds of sockets at one time, your only limited by how much memory you have given PHP or how many sockets your OS can handle.

printf