Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Connect to a socket server using applet

 
xikan wang
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm coding a socket program using VaJava 4.0.
I met a problem which was that I could't establish the connection between the socket server and the client that was an applet. I have been successfully running the server to listen, but when I used "new Socket(host, port)" to get a socket instance, an AccessControlException was thrown, which was associated with a SecurityPermission object. Then I assigned the previlege by calling function AccessController.doPrivileged, but it didn't work. Would you please help me? Thank you!
 
Jack Liang
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are serveral steps. First of all you need to sign your applet. This will based on what kind JVM you support in your browser side:
1. If use Microsoft VM, you need to sign your applet as a CAB file. In your code, you need to add following code before you make any network calls: PolicyEngine.assertPermission(PermissionID.NETIO);
You will need SDK tools: "makecert", "signcode"
2. If use Sun's JVM, make sure it is signed as JAR files. You will need "keytool" and "jarsigner".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic