recently i was trying to test a game i have been working on. i have been working on this game on and off for a while and it involves sockets. to test the game i usually just run the server application and the applet connects to "localhost". however it seems with a recent update of java, applets loaded on the same machine no longer have permission to access "localhost". whats the best way around this for me to keep testing my game? if at all possible i do not want to modify the permissions file. if i ever put this game on the net applets are still allowed access back to the host server without modification of the permissions file right?

Being able to access both localhost and the server the applet was loaded from sounds like a pretty huge security flaw, so I wouldn't count on being able to do that ever again.Were you testing it on a locally hosted server before?

im still relatively new to java but a month or two ago i could run my server application and the game applet all on my computer. Im using sockets and the code in the server looks like

1

ssock = newServerSocket(4444);

4444 or any arbitrary port number used to work.

and the applet has code like

1

sock = newSocket("localhost",4444);

i dont have a server i was just trying to simulate internet play all on the same machine so i could test my game. this method worked a month or two ago and i recently tried to run my game again(no changes to any code) and i get the AccessControlException....

whats the best way for me to keep simulating internet play all on the same machine?

If you want to use sockets you'll need to sign the applet to give it permission to do so.Sockets are not ideal for applets for this reason, but if people are prepared to accept your certificate (a la Runescape) it'll work fine.

ok well since my applet isn't loaded on any webpage what does that mean? im just generating the applet using an applet viewer (ie. BlueJ). i tried port 80 it still does the same thing. i dont understand why this is so complicated. does no one create internet games using applets? if so how do they test them?

And that's why you can connect to a sql server on a totally different port?

You can only connect to localhost if the applet is hosted on the client. Better said you can only connect to the host that hosts the applet. Only if the host that hosts the applet happens to be the localhost can you connect to it.

There is a difference between:- where the code is run, dictates what localhost is- where the code orientates from, dedicates where you can connect to.

even with getHost() i dont think it will work because of a recent java update. as for signing i thought applets could connect back to the host server without being signed???

if sockets are not ideal for applets what is a better approach? and if the applet must be signed what exactly does that mean and how do you do it?

An applet can connect back only to it's host and only on 'the web' port 80. Signed applets can connect to any host, any port, anywhere.Free server & signed applets - if you want fast comms you'll need both!

i tried what you suggested Riven and it still does the same thing. the code i posted used to work and now it doesn't even though i didn't change anything. however, i did change my computer from xp to vista.... would that maybe have something to do with it?

"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

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.

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.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org