Topic: 如何在Applet中使用套接字

  Print this page

1.如何在Applet中使用套接字 Copy to clipboard
Posted by: guoyanqi
Posted on: 2005-06-03 10:35

在Applet 中使用 socket连接时 总是连接不上 但是用java应用程序连接时则可以连接上 请各位高手指点一二

2.Re:如何在Applet中使用套接字 [Re: guoyanqi] Copy to clipboard
Posted by: hitzsf
Posted on: 2005-06-04 00:59

那当然了,applet运行在浏览器的虚拟机里,权限被限制了呗!
完全是为了安全考虑

3.Re:如何在Applet中使用套接字 [Re: guoyanqi] Copy to clipboard
Posted by: why
Posted on: 2005-06-04 01:58

http://java.sun.com/sfaq/#socket
How can an applet open a network connection to a computer on the internet?
Applets are not allowed to open network connections to any computer, except for the host that provided the .class files. This is either the host where the html page came from, or the host specified in the codebase parameter in the applet tag, with codebase taking precendence.

For example, if you try to do this from an applet that did not originate from the machine foo.com, it will fail with a security exception:

  Socket s = new Socket("foo.com", 25, true);


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923