• Post Reply Bookmark Topic Watch Topic
  • New Topic

Applet can make Socket Connection.

 
maateen ashraf
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 )
 
maateen ashraf
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 583
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ashraf
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
gautham kasinath
thanx for ur help...
i'll try it..
 
Ravee Bhat
Ranch Hand
Posts: 72
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello, Carl Trusiak
thanx for ur cooperation...
i would be sending u the code
but let me first check...
again thanX
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!