aspose file tools
The moose likes Sockets and Internet Protocols and the fly likes Applet can make Socket Connection. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "Applet can make Socket Connection." Watch "Applet can make Socket Connection." New topic
Author

Applet can make Socket Connection.

maateen ashraf
Ranch Hand

Joined: Jan 08, 2001
Posts: 122
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
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 )

I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
maateen ashraf
Ranch Hand

Joined: Jan 08, 2001
Posts: 122
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
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);


"In the country of the blind, the one eyed man is the King"
Gautham Kasinath CV at : http://www.geocities.com/gkasinath
maateen ashraf
Ranch Hand

Joined: Jan 08, 2001
Posts: 122
hello
gautham kasinath
thanx for ur help...
i'll try it..
Ravee Bhat
Ranch Hand

Joined: Nov 26, 1999
Posts: 72

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
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
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
hello, Carl Trusiak
thanx for ur cooperation...
i would be sending u the code
but let me first check...
again thanX
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet can make Socket Connection.
 
Similar Threads
What's wrong here!
Applet Security
can applet read form a file on host machine
Blocking system props from Applets ...?
Passed part-I with 91%