tags:

views:

1105

answers:

4

Is it possible to let the web server send a message to the web browser without Comet?

Every major web company like Facebook and Google uses Comet for this purpose and it just seems like an ugly hack waiting to disappear if tcp connections were enabled for major browsers.

+2  A: 

Why do you think Facebook and Google would do it if there were another way?

Well, OK, there are other ways. You could embed a Java applet in the page. If the Java applet is signed, and the user gives it permission, it could open up a long-running connection for the server to send it events. But that would get you something that was more fragile, required more user interaction, was slower to start up, and would work on fewer platforms than Comet.

There has been some discussion of adding server-sent events and web sockets to HTML5, but that's extremely preliminary and probably won't make it into the standard.

Brian Campbell
+1  A: 

As "Comet" is an artificial term for anything which uses the existing http protocol to simulate a push of data I fear there is nothing you can do.

The only solution would be an "enhancement" of the current protocol or some widely used probably plugin based solution ... you can use java for that. But this will rise other problems because basically you need to have incoming connection on that browser available.

OderWat
+2  A: 

Comet can be implemented as just a long-polling ajax call, so it gets to be a matter of semantics. Here, for example, is a jquery plugin that implements Comet using the Bayeux protocol atop jQuery's ajax call.

Scott Evernden
+5  A: 

Is it possible to let the web server send a message to the web browser without Comet?

Yes, its possible via Silverlight, Flex, Flash and Java Applets.

Every major web company like Facebook and Google uses Comet for this purpose and it just seems like an ugly hack waiting to disappear if tcp connections were enabled for major browsers.

TCP connections a la HTML 5 Web Sockets won't solve the problem. You see a lot of people use Google and Facebook from their workplace, university or school and firewalls often block non-standard ports, and non-HTTP traffic. So a solution which sends messages to a web browser has to work over HTTP and often look like HTTP. That's why Google and Facebook use Comet and will continue to do so otherwise they won't be able to reach a large percentage of their users. In fact, some firewalls and reverse proxies will close long-running HTTP connections and so an Ajax polling connection is often used as a fallback. I can suggest something like StreamHub Reverse Ajax if you are looking for a server that is capable of sending messages to the browser via Reverse Ajax.

Supertux
See: http://stackoverflow.com/questions/1227266/how-do-i-open-a-connection-back-to-the-server-using-flex
DLauer
And http://stackoverflow.com/questions/1225147/how-do-i-open-a-tcp-socket-from-silverlight
DLauer