aspose file tools*
The moose likes Applets and the fly likes SocketPermission Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "SocketPermission" Watch "SocketPermission" New topic
Author

SocketPermission

Jochem Gruter
Greenhorn

Joined: Aug 16, 2011
Posts: 9
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
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Applets need to be signed if they want to connect to sockets. So, sign the applet.
Jochem Gruter
Greenhorn

Joined: Aug 16, 2011
Posts: 9
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
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Jochem Gruter wrote:won't work.


That could mean a lot of different things. Read this: TellTheDetails.
Jochem Gruter
Greenhorn

Joined: Aug 16, 2011
Posts: 9
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

Joined: Oct 27, 2005
Posts: 19784
    
  20

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SocketPermission