• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SocketPermission

 
Jochem Gruter
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I made a client-server based multiplayer game with java. When I run the client in eclipse it works fine. But when I run the game in a browser I got this error:

c:\**********>Appletviewer -J-Dos400.awt.native=true -J-Djava.version=1.5 launch.html
Exception in thread "Thread-5" java.security.AccessControlException: access denied (java.net.SocketPermission ***ip*****:7777 connect,resolve)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkConnect(SecurityManager.java:1034)
at java.net.Socket.connect(Socket.java:524)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.<init>(Socket.java:375)
at java.net.Socket.<init>(Socket.java:189)
at net.Connection.send(Connection.java:22)
at client.Castle.run(Castle.java:83)
at java.lang.Thread.run(Thread.java:662)


How can I solve this?
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Applets need to be signed if they want to connect to sockets. So, sign the applet.
 
Jochem Gruter
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Applets need to be signed if they want to connect to sockets. So, sign the applet.


I did this:

keytool -genkey -keyalg rsa -alias MyCert


jar -cf myapplet.jar client/Castle.class


jarsigner myapplet.jar MyCert


but won't work.
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jochem Gruter wrote:won't work.


That could mean a lot of different things. Read this: TellTheDetails.
 
Jochem Gruter
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The client is just sending sockets to the server and the server reply. This is the code to send a socket (client side):



And here the code from the server that receive the sockets and reply:

 
Rob Spoor
Sheriff
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That code may work, once you get the applet properly signed. If you're still getting that exception then it's not yet.

I'll move this thread to our Applets forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic