Solved

Starting a ServerSocket from an Applet

Posted on 1997-06-23
4
508 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

770 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