• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • Last Modified:

How do socket communicate with host by applet?

I have meet a problem following that recentainly:  
   Why can't the client send the message to server in UDP programing When I use applet and frame ?
   There are the following error in java control:
//************************************************//
com.ms.security.SecurityExceptionEx[JIMMessage.feedback]: cannot access 6767
   at com/ms/security/permissions/NetIOPermission.check
   at com/ms/security/PolicyEngine.deepCheck
   at com/ms/security/PolicyEngine.checkPermission
   at com/ms/security/StandardSecurityManager.chk
   at com/ms/security/StandardSecurityManager.checkListen
   at java/net/DatagramSocket.create
   at java/net/DatagramSocket.<init>
   at java/net/DatagramSocket.<init>
   at JIMMessage.feedback
   at JIMEnter.actionPerformed
   at java/awt/Button.processActionEvent
   at java/awt/Button.processEvent
   at java/awt/Component.dispatchEventImpl
   at java/awt/Component.dispatchEvent
   at java/awt/EventDispatchThread.run
com.ms.security.SecurityExceptionEx[JIMMessage.feedback]: cannot access "192.168.0.3":6767
   at com/ms/security/permissions/NetIOPermission.check
   at com/ms/security/PolicyEngine.deepCheck
   at com/ms/security/PolicyEngine.checkPermission
   at com/ms/security/StandardSecurityManager.chk
   at com/ms/security/StandardSecurityManager.chkex
   at com/ms/security/StandardSecurityManager.checkConnect
   at java/net/DatagramSocket.send
   at JIMMessage.feedback
   at JIMEnter.actionPerformed
   at java/awt/Button.processActionEvent
   at java/awt/Button.processEvent
   at java/awt/Component.dispatchEventImpl
   at java/awt/Component.dispatchEvent
   at java/awt/EventDispatchThread.run
Exception occurred during event dispatching:
com.ms.security.SecurityExceptionEx[JIMMessage.feedback]: cannot access "192.168.0.3":6767
   at com/ms/security/permissions/NetIOPermission.check
   at com/ms/security/PolicyEngine.deepCheck
   at com/ms/security/PolicyEngine.checkPermission
   at com/ms/security/StandardSecurityManager.chk
   at com/ms/security/StandardSecurityManager.chkex
   at com/ms/security/StandardSecurityManager.checkConnect
   at java/net/DatagramSocket.send
   at JIMMessage.feedback
   at JIMEnter.actionPerformed
   at java/awt/Button.processActionEvent
   at java/awt/Button.processEvent
   at java/awt/Component.dispatchEventImpl
   at java/awt/Component.dispatchEvent
   at java/awt/EventDispatchThread.run
//**********************************************//
If you can tell me,I would send all my points!Thank you!

0
coffeetea
Asked:
coffeetea
  • 2
1 Solution
 
tonusCommented:
Applet can communicate only to the server from which it is loaded. Because of client side security features, You are not allowed to access any other resources from the applet.
   Otherwise you have to grant permissions in the client side by manipulating the policy file located at
C:\Program Files\JavaSoft\JRE\1.3.0_02\lib\security\java.policy (if the browser uses jre plug-in) or you got sign the applet.
0
 
sobhan_genieCommented:
What tonus said is correct I guess in addition to it these are the lines u have to add in the java.policy file

// allows anyone to listen on un-privileged ports
permission java.net.SocketPermission "localhost:1024-, "listen";

              This says on local host applets can listen on to any ports >= 1024. If you want it to be only 1024 then remove the - suffix.


// allows anyone to listen on un-privileged ports
permission java.net.SocketPermission "172.20.34.148:1729", "listen,accept,connect";

            The same thing above if you are about to access a remote machine you have to do this.

             Hope this helps.
bye,
Sobhan

0
 
coffeeteaAuthor Commented:
Thank for your answer!I'll send all my points to you!
But now I have 70 points only,so I'm about to send 50 points to tonus ,and I'll send another 50 points to
sobhan_genie later!Thanks!
0
 
coffeeteaAuthor Commented:
Dear sobhan_genie :
   I have 50 points,but I don't know how to send to you!
It's seemed that there is no way to send points again!  
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now