Mawg
Mawg

Reputation: 40145

Receive input over TCP/IP and use it to update HTML

This has got to be a FAQ, so can someone please just direct me to a "network programming for dummies" URL?

The server wants to push information to a client or broadcast to all, when an event happens - as opposed to the clients constantly polling the server "just in case". The client then updates a browser page display.

How do I do that? (toldya it was a n00b question)

Should I have a thread which receives info on a socket and then writes it to a database which the browser display (PHP) can process with an HTML refresh tag, or what?

Sorry to sound so dumb.

Upvotes: 2

Views: 378

Answers (4)

mozillanerd
mozillanerd

Reputation: 560

THere are multiple ways to skin this onion: 1.iframes with a timer 2.ajax. 3.comet - server push 3. etc

and don't forget the latests html5 websockets - perhaps even IE9 : http://ezinearticles.com/?HTML5-Web-Sockets-Example&id=4239499

Upvotes: 1

mozillanerd
mozillanerd

Reputation: 560

Perhaps and obvious answer in the previous post can solve the 'problem'. Another way is to automatically force the browser to refresh the page. The server can then provide information that can be used by the browser. Use the meta tag with attributes refresh and content

Upvotes: 1

Mawg
Mawg

Reputation: 40145

Sorry, folks, the obvious answer is http://en.wikipedia.org/wiki/Push_technology#HTTP_server_push

Upvotes: 2

Jeff Fohl
Jeff Fohl

Reputation: 2076

I think you might be looking for something like comet: http://en.wikipedia.org/wiki/Comet_%28programming%29

Comet is sort of the opposite of polling, where you have a long-standing HTTP connection, which allows you to push data to the client from the server. Unfortunately, I don't have much to lend other than a link like the one above, but hopefully it will start you in the right direction.

Some more links that might be helpful:

https://stackoverflow.com/questions/tagged/comet

http://ajaxpatterns.org/HTTP_Streaming

Upvotes: 2

Related Questions