Socket programming inside a servlet acting as server, is it a good solution to start a sort of server pushing environment?
views:
331answers:
1
+1
A:
I wouldn't do socket programming from within a servlet; you're likely to have all kinds of problems if the socket outlives the Request which initiates it.
Take a look at the cometd project. Comet is a technology for doing HTTP-push (basically, you hold an HTTP connection open for an arbitrarily long time, and the server pushes events down to the client as they occur, rather than waiting for the client to poll). You need a web server which will scale to support a large number of mostly-idle connections, but that's not hard these days, and the cometd project has a number of implementations available for download. You could use theirs, or just take a look at it for inspiration if you want to build your own.
Chris May
2009-04-08 19:53:11