Solved

Starting a ServerSocket from an Applet

Posted on 1997-06-23
4
511 Views
Last Modified: 2008-03-06
I would like to support applet to applet communication
without having to start a server socket by hand (from the command line).
I really would like to start the server socket from an applet, and if at all possible I would even like the server socket's life to be independent from the applet's.
Is this in any way possible.
I was thinking of writing a server-side application to support the server socket, and let the applet create the application through a call to the server (Our Oracle WebServer supports server-side applications rather than server-side applets).
However, the application would never return!
I could keep the applet from hanging up by using a separate thread, though I'm afraid the application will stop as soon as the applet dies.
I want this socket server to serve the communication between many applets/people. I would like to end the server only when all users have stopped listening.
The only other solution I can think of is to create a separate server for each person, but that would really be overkill.
0
Comment
Question by:stouffs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Expert Comment

by:jpk041897
ID: 1221960
There is a couple of solutions I can think of:

1.- URLConnection allows you to post/send to a CGI. The CGI could be a program (or shell script) that launces your server.

2.- You could use servlets if your using JDK1.1+

Which soloution sould work better for you?
0
 

Author Comment

by:stouffs
ID: 1221961
I would like to use your first solution, I can't use JDK1.1 yet.
The CGI program is a java application in my case.

0
 
LVL 2

Accepted Solution

by:
Philippe earned 120 total points
ID: 1221962

Stouffs,

what you want, is very similar to a chat server. There is an article on chat servers currently on webmonkey:

 http://www.hotwired.com/webmonkey/code/

If you use a cgi then every applet will execute the cgi once. Cgi are good for request-response type of applications. It seems you want the applets to exchange data or to get updates as long as they are connected. You also you want serveral applets to connect to the server at the same time. In that case it is better to write a server which will be listenning on a given port for incomming connections from applets. The proper way to start a server in that case is to always run it (eg start it at boot time).

 hope this helps,

   Philippe

0
 
LVL 6

Expert Comment

by:jpk041897
ID: 1221963
You will probably wnat to look at:

http://www.inf.uni-hohenheim.de/top/java/tutorial/networking/urls/readingWriting.html

which has somewhat detailed information on how to send a post to a CGI from Java.

As long as the program you call deos not end, it will remain active.

As to the invocation itself. Its realy implementation specific. My advise would be to call a program that forks and spawns your server, and then ends, in order to release the connection resoources needed to call the CGI. The advantage of this is taht you can return a value indicating success/failure via stdout (standard CGI output).
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question