Can an Applet make a socket connection with Server from where it is loaded... i think yes as when we study applet security FAQ http://java.sun.com/sfaq/
Carl Trusiak
Sheriff
Joined: Jun 13, 2000
Posts: 3340
posted
0
Yes you can and the easiest way to determine which server it can connect to is to run a little test applet with a single label and set the text of that label to this.getCodeBase(). Then you can use a socket to connect to any port where you have a Server listening on that Machine. Take a look at the Custom Networking Tutorial (Welcome back )
hi Carl Trusiak thanx for ur help, i did the same but still my application is not running .... when we run applet then myApplet.getCodeBase() gives the following "file:/D:/sockets/newSocket/" but when i download this same applet form browser then it just throughs the following security exception. com.ms.security.SecurityExceptionEx[TheClient.init]: Unable to check hostname "http://192.168.0.249/sockets/newSocket/". 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/InetAddress.getAllByName0 at java/net/InetAddress.getByName at java/net/Socket.<init> at TheClient.init at com/ms/applet/AppletPanel.securedCall0 at com/ms/applet/AppletPanel.securedCall at com/ms/applet/AppletPanel.processSentEvent at com/ms/applet/AppletPanel.processSentEvent at com/ms/applet/AppletPanel.run at java/lang/Thread.run com.ms.security.SecurityExceptionEx[TheClient.init]: Unable to check hostname "http://192.168.0.249/sockets/newSocket/". 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/InetAddress.getAllByName0 at java/net/InetAddress.getByName at java/net/Socket.<init> at TheClient.init at com/ms/applet/AppletPanel.securedCall0 at com/ms/applet/AppletPanel.securedCall at com/ms/applet/AppletPanel.processSentEvent at com/ms/applet/AppletPanel.processSentEvent at com/ms/applet/AppletPanel.run at java/lang/Thread.run Microsoft (R) VM for Java, 5.0 Release 5.0.0.3031 thenX in advance
gautham kasinath
Ranch Hand
Joined: Dec 01, 2000
Posts: 583
posted
0
hey! there shouldnt be any problem to connect to a server of your choice from an applet.. well run the server and in a thread other than the GUI connect to the Server by using the fiollwouing syntax.. Socket cSoc = new Socket(String strServerIP, int intPort);
Maateen I am just curious about this thing. Do you get the same exception in netscape browser? thanks and regards ravee.
maateen ashraf
Ranch Hand
Joined: Jan 08, 2001
Posts: 122
posted
0
hello,Ravee Bhat yea its also throwing the same exception in Netscape... i would also send u the complete exceptions if u require... bye
Carl Trusiak
Sheriff
Joined: Jun 13, 2000
Posts: 3340
posted
0
Maateen, Try running all the code from this post http://www.javaranch.com/ubb/Forum8/HTML/000181.html If this still causes the exceptions you are seeing, you need to take a look at the policy file that is installed on your system.
maateen ashraf
Ranch Hand
Joined: Jan 08, 2001
Posts: 122
posted
0
hello, Carl Trusiak thanx for ur cooperation... i would be sending u the code but let me first check... again thanX