?
Solved

Socket-connection from an applets init()

Posted on 1998-09-02
4
Medium Priority
?
291 Views
Last Modified: 2010-03-30
When I create a socket in the init()-method of my applet, there occures a SecurityExceptionEx(Host):cannot access 'port'
This exception only occures when I load the html-page from my local machine - when I load it from the server the connection succeed.
All class-files are stored on my local machine (also the applet)
What does I have to configure on my local machine?
0
Comment
Question by:Hugi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 6

Expert Comment

by:gadio
ID: 1223293
Hugi, the problem is that when you run it locally, your machine is both the client and the server. That may cause on some browsers to refuse to load images and to open socket connections. What you can do is to
1. In order to test your applet use appletviewer.
2. If you insist on using a browser, install one of the tiny freeware http servers on your machine, and activate your applet from "the server" that actually operates on the same machine.
In order to find small basic http server serch in:
www.gamelan.com
www.developer.com
www.download.com

Hope that helps, G.
0
 

Author Comment

by:Hugi
ID: 1223294
appletviewer does not work and I don't want to set up my local machine as a web-server.
0
 

Expert Comment

by:iliya
ID: 1223295
There is one limitation which can cause the problem:
The applet in the browser (like Netscape or IE) can create connection only with the site with the server, from which the HTML page is loaded.
And what socket you create in your applet? To which IP address and port you try to connect?
0
 
LVL 1

Accepted Solution

by:
Twix earned 300 total points
ID: 1223296
Hello Hugi,

You are looking at a couple of different issues here:
1.)The web browser you are using creates a different security model depending where the applet is loaded from. Applets are designed from the aspect of loading off a Server. Not running a server may mean the applet may not behave as expected.

2.) You will still have to use relitive URL's for all the files you load. This should get you past any security restrictions there. If you are having to package classes, be abolutly sure that they are found only, only, only in the directory structure below the applet. If they are found anywhere else on the class path it will not work. (You don't have to worry about the JDK classes as long as the ones from your browser company are the only ones loaded).

3. If you make a connection, it may have to be to 127.0.0.1. If you load it off the local file system, local host may be the only IP you can connect to. If security is turrned on in applet viewer this is the case. If it is turrned off, it can connect anywhere.

For IE, and Netscape, you cannot set Via the GUI low enough security restrictions to connect anywhere. For IE, I have a .reg file that I can e-mail to you if you like that will enable this.
For Netscape, you will have to check their documentation on how to enable this.

e-mail me at todde@rio.com if you want the .reg file for IE!

Twixter
Java Smarty Guy/Programer
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This video teaches viewers about errors in exception handling.
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question