Solved

Starting a ServerSocket from an Applet

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now