Forums Register Login

Applet serversocket problem

+Pie Number of slices to send: Send
Hi all,

I have read most of the threads on applets and serversockets but as yet cannot come up with a solution to my problem...

I am writing an application which connects to a remote server, and to do this i used serversockets. I want now to implement an applet version. I looked into it before and couldnt, applets can only connect to the machine the applet is running on. I know about the security restrictions...but read that I might be able to get around that. Also someone wrote something about signing the connection. Im not sure but can you please help?

Thatnks in advance,

Dan
+Pie Number of slices to send: Send
The The Java Tutorial: Applet Security Restrictions explains what applets can and cannot do. You have two options. You can use your server to do the dirty work and report back to the applet:
The Java Tutorial: Working with a Server-Side Application or you can digitally sign the applet, assuring the user that you are who you say you are and that the applet code has not been tampered with: Advanced Programming for Java 2: Signed Applets
+Pie Number of slices to send: Send
HI,

I have done smething similar ...Applets can make socket connections to servers other than the server that it came from ( though I think the server has to be running on the same machine as the web-server the applet came from).
Here are a few links ..for chatserver and clients they have applets creating sockets with the server:
http://www.csse.monash.edu.au/~lloyd/tildeProgLang/Java/Chat/
http://servlets.com/jservlet2/examples/ch10/#ex10_15

Hope this helps.
-G.
[ January 06, 2005: Message edited by: Gauri Deshmukh ]
+Pie Number of slices to send: Send
Thank you for the replies. I have been working through the examples. Does anyone know about changing the .policy file to allow socket connections?
+Pie Number of slices to send: Send
Advanced Programming for the Java 2 Platform: Security and Permissions
Be advised that you will have to install the profile file on every client. Probably not what you want to do if you are writing an applet.
I think Gauri is confused with your use of "server" to mean a physical machine as opposed to a piece of software (i.e. a web server or database server). To clarify what he was trying to say, an unsigned applet can open a socket on any port as long as the IP address is the same as the one it was downloaded from.
+Pie Number of slices to send: Send
Joe,

Thanks for that. I was able to get the applet working and connecting to a serversocket. I know it shouldnt work when trying to connect to a serversocket on a different machine, but can I do this. Also I am a bit confused about the process of signing and unsigned applets. If I run my applet from a webserver on the same machine that is hosting the serversocket and then access the applet from a remote client, should it work?

Cheers,
Dan
+Pie Number of slices to send: Send
 

Originally posted by Dan Lynch:

I know it shouldnt work when trying to connect to a serversocket on a different machine, but can I do this.



Would you by any chance be using the appletviewer provided with the JDK or be loading the HTML file directly from the file system (as opposed to loading it through a web server? That should work, as is Documented in the Applet Security FAQ


Also I am a bit confused about the process of signing and unsigned applets. If I run my applet from a webserver on the same machine that is hosting the serversocket and then access the applet from a remote client, should it work?


The applet is downloaded from the same IP address that it attempts to contact in this scenerio, so it should work signed or unsigned. The FAQ covers that as well.
+Pie Number of slices to send: Send
Hi guys,

What I am trying to do is run an applet, from the serversocket machine... and allow people to access the applet remotely.

The applet is downloaded from the same IP address that it attempts to contact in this scenerio, so it should work signed or unsigned. The FAQ covers that as well.



So acces the applet on the hachine from which it is hosted? From remote acces does every client have to download the .policy file?

Would you by any chance be using the appletviewer provided with the JDK or be loading the HTML file directly from the file system (as opposed to loading it through a web server?



I am loading the applet into a webpage and accessing the file system directly. I wanted to get this working before I tried it on a webserver. So the machine running the serversocket has to also host the applet? Just wondering as I will have to install the webserver on the serversocker machine and it would be much simpler not to.

Yhanks for the help thus far.

Dan
Once upon a time there were three bears. And they were visted by a golden haired tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2316 times.
Similar Threads
Re: File Transfer using Java
Creating Java applet
applet restriction question
Applets and sockets
Running Applet in JFrame
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 08:25:39.