Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] Applet <-> Socket

Started by lkingx Mar 23, 2000 at 2:02 PM 5 replies 1.1k views
Original Post
lkingx
lkingx
Hello, can i connect me to a socket from an applet, when the socketserver isn''t on the same pc as the applet?
eqs
eqs
If what ive understood what ive been reading then the answer is no. It violates the security thingy that Sun has got put on applets.

That description sucks, so I hope one of the smart people answers this post too.

PEACE
GAZZ
lkingx
lkingx
Sorry for my bad english, because Im from germany.
joeG
joeG
It''s supposed to be valid for you to connect to the server that the applet is downloaded from, nowhere else. However I''ve heard that in practice that sometimes does not happen.

JoeG
joeG
Jerry Lynn
Jerry Lynn
With Java versions 1.1 and earlier you can communicate with the server that served the applet, but not any other server (and I think you are even prevented from communicating with other sockets on the machine executing the applet? Does anyone know if the sandbox allows this?).

It is also possible to connect to socket servers on machines other than the one serving the applet if you modify the security policies on the computer executing the applet (at least with JDK 1.2 and greater).

Modifying security policies is not something you can expect the average user to be able to do. It also requires JDK 1.2+ support, meaning that the user has to have the Java 2 Plugin installed (since almost every browser only supports the 1.1 and earlier versions of the Java platform).

So if this applet is designed to be distributed to the Internet you will have to only communicate with the server that served the applet in the first place.
Jim_Ross
Jim_Ross
You can always connect to URLs to get files, but you cannot send anything besides a GET, or maybe a POST. So opening a socket to a server that isn''t the one that the applet is from is kind of a far out thing to do, unless you are writing and irc, ftp, or some similar client. I believe that with an electronically signed applet it is possible to connect to foreign sockets without modifying the security manager of the client''s computer, vis gamedev''s java irc client.

Other than that, one workaround would be to have the client download the applet from the server to which it needs to connect. The applet doesn''t have to reside on the web server that serves up the webpage that has the applet.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.