applets no longer have permission to access "localhost"???

running any firewalls?

I had a Vista issue that’s sounds very similar.

See relevant thread here http://www.java-gaming.org/index.php/topic,19960.msg159489.html#msg159489

When you create the socket, don’t include http:// in the host name.
You can have the http:// on XP and it works just fine, but on Vista you get a security exception.

To verify if this is your issue, you could try

new ServerSocket("127.0.0.1",4444)

and then point your browser to
http://127.0.0.1/client.html (or whatever the name of the page holding your applet is)

I’m confused afaik : and / aren’t legal characters for a hostname.

“RFCs mandate that a hostname’s labels may contain only the ASCII letters ‘a’ through ‘z’ (case-insensitive), the digits ‘0’ through ‘9’, and the hyphen. Hostname labels cannot begin or end with a hyphen. No other symbols, punctuation characters, or blank spaces are permitted.” http://en.wikipedia.org/wiki/Hostname

I’m also pretty sure

new ServerSocket("127.0.0.1",4444)

corresponds to
http://127.0.0.1:4444/client.html

which if you would enter in your browser will open a tcp connection to 127.0.0.1 and port 4444(if omitted it’s 80)

ok im not entirely sure but im getting the same exception as in your other thread wildern…

java.security.AccessControlException: access denied (java.net.SocketPermission 127.0.0.1:4444 connect, resolve)

this error occurs with

new ServerSocket("127.0.0.1",4444);  and new ServerSocket("localhost",4444);

also something interesting to note is that i get the exact same error regardless of whether or not i run the server application but as i already said the server throws no exceptions thus it should be connected to the correct port and host.

if this is the same sort of problem you had wildren how do i fix it since i do not make reference to http:// in my code?

edit: yes i have a mcafee firewall and windows defender is running. i had the same firewall on my xp install and it caused no problems.

As you get the exception from the SecurityManager, there is no way a firewall can cause this.

yea i didn’t think the firewall was the issue. since i get the same exception regardless of whether or not i run the server program, would the exceptions for not being able to bind to the host and the host not existing be the same?

I am not really sure how to help, I will see if I can get the test applet you provided up an running in a VM.
Maybe some more questions will provide a clue.
What webserver are you running, apache?
What browser are you using?
Do you get the same result using a different browser?
What is the URL you enter in the browser?

try running them as applications to test them.
i think youll find that you will need to sign the applet or jar to let them do anything that involves i/o.
Im suprised your not getting an i/o port already in use error.

I showed you an applet that successfully connects to it’s host and downloads a file. It is not signed.

If everything else fails, just copy everything from my sourcecode, and try to integrate it in your app.

Gonna try and steal your code riven :D…
will it work also for accesing resources on a different host? or does it have to be signed then probably will wont it ?

hmm stuck please show ;D


	public static void URLReader() {

		try{
			URL kickassip = new URL("http://www.kickassevolution.com/coreservers.html");
			BufferedReader in = new BufferedReader(new InputStreamReader(kickassip.openStream()));

			kickass.regip = in.readLine().toString();
			
			in.close();
	
		}
		
		catch(Exception e){
		
		}
	
    }


I dont think it will work as i have to use this from a remote server :-\

only the host that hosts your jar files (the code base)

anyway, always do something with your exception, if nothing else, print them, using e.printStackTrace()

[quote]Maybe some more questions will provide a clue.
What webserver are you running, apache?
What browser are you using?
Do you get the same result using a different browser?
What is the URL you enter in the browser?
[/quote]
im not running any webserver.
im not using a browser either.

im running and coding the applet from a program called BlueJ.
as for the server application im just running it from the windows command prompt.

as i said before im just trying to test out connections and stuff…i had a working client applet and server application and for some reason all of a sudden im getting the error i posted above.

You could try making an html page in the directory with your class files that has an applet tag

<html><head></head><body>
<applet code="yourmain.class" width= height=></applet>
</body></html>

Then, open that file in a browser and see if you get the same error.

??? If you’re not using a browser, why use an applet?
If you wrap your app within a Frame instead of within an Applet, it could then do anything it liked with sockets.

In short: if your game is a download (eg webstart) then use a Frame, if your game will run in a browser then use an Applet (but you must observe the sandbox restrictions for sockets; same host, same port - see Riven’s applet).

i will try your suggestion wildern and see what happens.

im not currently using a browser but if i ever put the game out there i kinda wanted it to just be an applet on a page not something the users had to download. also im aware of the sandbox restrictions and i dont think im currently violating any of them. i posted the entire code for applet and server that i tried. if there is something wrong with it please point it out.

also while on the subject of files…does the server application file need to be in the same file as the applet? or would anything like that throw the exception im getting?

I was able to reproduce your issue on my XP machine.
It looks like you need to install Apache.
Once I installed Apache and put the HTML file with the applet tag and the testing.class file in the htdocs directory, I was able run the applet without a security exception.
Attempts to open the HTML file in a browser or with appletviewer without using Apache all resulted in the security exception.

Well, it makes sense. If your protocol is “file://localhost/C:/…/” instead of “http://www…”, your codebase would be your applet folder, and all subfolders. This would be a major security issue, and you’d be able to read all files if your applet was placed in your C:\ root. After that, you can use [liveConnect + image request] to send the gathered data to another server.

So you need an http-host, not a file system.