Page doesn't load untill socket is completed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Hassanur
Forum Newbie
Posts: 1
Joined: Wed Dec 20, 2006 11:47 am

Page doesn't load untill socket is completed

Post 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"
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
printf
Forum Contributor
Posts: 173
Joined: Wed Jan 12, 2005 5:24 pm

Post 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
Post Reply