Solved

Socket-connection from an applets init()

Posted on 1998-09-02
4
281 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 100 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

732 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