开发者

Exception is caught during establishing the connection between server and client...!

开发者 https://www.devze.com 2023-02-02 21:51 出处:网络
hello guy\'s just written a program for Client and server. While i put \"127.0.0.1\" or \"localhost\" it works perfectly but while i assign my own ip or may be some of my friend ip.

hello guy's just written a program for Client and server. While i put "127.0.0.1" or "localhost" it works perfectly but while i assign my own ip or may be some of my friend ip. It doesn't work and give an exception like this

java.security.AccessControlException: access denied (java.net.SocketPermission 27.112.123.254:4444 connect,resolve)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:342)
    at java.security.AccessController.checkPermission(AccessController.java:553)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
    at java.lang.SecurityManager.checkConnect(SecurityManager.java:1051)
    at java.net.Socket.connect(Socket.java:541)
    at java.net.Socket.connect(Socket.java:495)
    at java.net.Socket.<init>(Socket.java:392)
    at java.net.Socket.<init>(Socket.java:206)
    at sas.actionPerformed(sas.java:25)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
    a开发者_运维知识库t javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:253)
    at java.awt.Component.processMouseEvent(Component.java:6175)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:5940)
    at java.awt.Container.processEvent(Container.java:2105)
    at java.awt.Component.dispatchEventImpl(Component.java:4536)
    at java.awt.Container.dispatchEventImpl(Container.java:2163)
    at java.awt.Component.dispatchEvent(Component.java:4362)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4461)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4125)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4055)
    at java.awt.Container.dispatchEventImpl(Container.java:2149)
    at java.awt.Component.dispatchEvent(Component.java:4362)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:604)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)

Please help me guy's...!!


Is this started as an applet? If so, you can only connect to the server from where the code originated unless you sign it.


I think you just smacked headlong in to the Java SE platform security system. Take a look at this information on the Java SE security model, specifically around the Permissions classes.

The java.net.SocketPermission classes control what ports the VM can access outside of the local machine. These are usually controlled by a Policy file somewhere around the VM (look at the VM documentation to figure out where this is). You will need to modify the policy file to allow the VM to access other sockets.

It isn't intuitive - in fact, it's a royal pain - but it is designed to keep the VM from doing whatever it wants.

0

精彩评论

暂无评论...
验证码 换一张
取 消