0

Following up on this question I was wondering is there is a way, without using socket.io, to avoid the buffering of the response that happens on most navigators. So for instance if the node server emit every 5 secondes : 'hello world' i can directly print them on a webpage as soon as the data is available.

Is there a way to do so ?

Community
  • 1
  • 1
silkAdmin
  • 4,640
  • 10
  • 52
  • 83

2 Answers2

1

Unfortunately, this is not how web browsers work. If you want this type of functionality without using WebSockets (or a socket.io fallback) you could try with Server-Sent Events. See this gist for an example (in coffeescript). Also, here is a polyfill for older browsers.

Linus Thiel
  • 38,647
  • 9
  • 109
  • 104
1

Yes, this is doable. This is how comet streaming servers work.

See http://faye.jcoglan.com/ for an example for Node.js.

Steve Campbell
  • 3,385
  • 1
  • 31
  • 43
  • Thanks this looks a lot like what i would need, are you by anychance aware of a PHP equivalent ? – silkAdmin Mar 22 '12 at 17:26
  • Not specifically. Googling "php comet server" has a few results, and also turns up this [related question](http://stackoverflow.com/questions/603201/using-comet-with-php). – Steve Campbell Mar 23 '12 at 03:27