This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Servlets and the fly likes Servlet-Applet: raw socket connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet-Applet: raw socket connection" Watch "Servlet-Applet: raw socket connection" New topic

Servlet-Applet: raw socket connection

Laurent Sate

Joined: Dec 18, 2001
Posts: 10
I must use a raw socket connection to communicate between a applet and a servlet because I want have a permanent connection between them. How Can I do that?
I have seen the DaemonHttpServlet class on How I can use it? What do I implement in the HandleClient method? And i my applet, how can i attack my servlet?
Thanks a lot!!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17276

You don't do "permanent" connections to servlets. A servlet behaves like a subroutine, not a program. It does not run as a process in its own right, and therefore there would be no way to make it stop and listen (or even poll and listen) for incoming messages.
If you actually need a true permanent connection, you'll have to set up an independent server for that purpose. If all you really needed was for the applet to do internal transactions, an HttpURLConnection makes a lot more sense
As far as persistent connections for the purpose of reducing connection overhead go, most modern-day webservers keep the pipeline open for a certain period of time after a request comes in in anticipation that there will be more traffic.

An IDE is no substitute for an Intelligent Developer.
I agree. Here's the link:
subject: Servlet-Applet: raw socket connection
It's not a secret anymore!