Applet which loads a map from a server

Hey this is my first post here it goes,

Ive made a 2D game where you control a circle man and shoot, the background of the game is made up of 32x32 tiles and it runs as an applet. I made a server program which loads lots of numbers from a file and stores them in a big integer array. Then once you load up the client game it connects to the server and downloads the big integer array from the server. Basicly every number represents a tile with diffrent properties exct that is used to lay out the map.

I complied the server and am running it by itself, and then i load the applet in eclipse and it works however when i run the applet in an actual browser (ive tried firefox and IE) it doesnt load the map, it runs but the map is blank meaning something has gone wrong getting the integer array from the server. Now i think this problem is probably something todo with security i dont know about ive tried disabling firewall on my computer and the port is fowarded correctly, as it works in eclipse.

any ideas? ???

tl;dr applet works in eclipse and browser but networking part of applet doesnt work in browser

That’s because it’s a security feature where an applet cannot connect to any IP address other than where it’s hosted. To be able to connect to another IP address, you will need to sign your applet.

EDIT: It also sounds like you are running in on localhost (127.0.0.1), which is blocked too.

Thanks for the response, i am connecting to my own ip address and the applet is hosted locally on my computer its not accessable via the internet so surely it is connecting to where its hosted?

EDIT: the socket is bound to my ip address not 127.0.0.1

Open the Java console and look for errors. It’s hard to diagnose anything before you do that.

Ah but you are hosting the applet on localhost. When you double click on any HTML file on your computer, it is run in localhost.

aggh thank you very much managed to fix it i think the problem was that i was running the applet localy on my computer so it thought it was hosted at 127.0.0.1 instead of my ip and localhost is blocked anyway. I fixed it by putting it in the ol’ webserver you can see it here

http://81.96.53.133/egg/WeaponHat.htm

so yea what you suggested thanks :smiley:

Yep I can connect fine too. Great job :slight_smile: