Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 04-11-2009
Member
 
Join Date: Nov 2009
Posts: 42
PHP server side programming

I state that I am approaching now the only server side programming (PHP) flavored with a bit of ajax, and I have a question that google can not answer (probably I'm using the wrong words):

I know the http 1.1 allows to maintain an open channel with the server, then the server can send "alerts" to the client without at that precise time is requested anything (as opposed to version 1.0 in which the connection was falling at the end of sending data, then only the client could make requests.)

But in practice what are the guidelines to implement something like that? Gmail works well, is it?
Reply With Quote
  #2  
Old 04-11-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: PHP server side programming

To create a script that continues to send data to the client that has enough time limit imposed with set_time_limit () and then you do not go out all the time, such as "stuck" in a while loop.

The only thing you must remember is that the buffer starts to be synchronized after the first 1024 bytes, so to have an output-so-mean real-time need to send anything to the client first 1024 bytes of output itself.

Delivery of data to print with functions such as customer support and echo each time the flush ().

I hope you make it clear, otherwise you do the tests and then think.
Reply With Quote
  #3  
Old 04-11-2009
Member
 
Join Date: Nov 2009
Posts: 42
Re: PHP server side programming

Thanks for detailed answer

Its clear to me. I am glad that you ask a few more details before you try some evidence, in particular:

- How to send 1024 bytes of null data to the client?
- On the client, how to trap the output with JS?

thanks, to clarify these aspects to do some tests
Reply With Quote
  #4  
Old 04-11-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: PHP server side programming

Quote:
Originally Posted by MAHESA View Post
Its clear to me. I am glad that you ask a few more details before you try some evidence, in particular:

- How to send 1024 bytes of null data to the client?
- On the client, how to trap the output with JS?

thanks, to clarify these aspects to do some tests
The first point is simple, you can just send a string of 1024 "spaces" using something like echo str_repeat ( "", 1024)

The second point I can not help you, but I suppose procedures require the use of AJAX. Ask again, maybe somebody who knows a JavaScript solution might also simplify you.
Reply With Quote
  #5  
Old 04-11-2009
Member
 
Join Date: Nov 2009
Posts: 42
Re: PHP server side programming

Just for my curiosity sake, if I understood right from the doc I need flush () because otherwise the server waits for the end of the script (which never ends) to send the various echo (), right?
Reply With Quote
  #6  
Old 04-11-2009
Member
 
Join Date: May 2008
Posts: 2,293
Re: PHP server side programming

Exactly, and how you responded.

For the first 1024 bytes is not enough to flush, mean you have to send at least that number of bytes because the browser will display (unless the script does not finish first, but it is not your case), but then you can request a flush ie an item to the browser, every time you want to for every single byte.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "PHP server side programming"
Thread Thread Starter Forum Replies Last Post
Server side Software for Network Audit Valdis Networking & Security 4 09-12-2010 10:05 AM
How to Configure Office to run server-side? Orton Windows Software 5 25-03-2010 05:39 AM
Problem in server side code New ID Software Development 5 25-01-2010 12:53 PM
What is SSI (server-side includes) and How should I use it? robin45 Windows Software 5 28-11-2009 05:18 PM
Difference between Server-side and Client-side code? Booth Software Development 2 08-01-2009 03:21 PM


All times are GMT +5.5. The time now is 10:25 PM.