Winsock with applets

Hi, I have winsock working on my own machine eg hosting and joining to localhost or 127.0.0.1
But I would like to make an applet where you can choose either to host or join a game and put it on my website.
Does it Have to be signed??? I don’t want it to be.

http://www-personal.umich.edu/~lsiden/tutorials/signed-applet/signed-applet.html

this is the thing. I will only be using sockets on my site for a game, so the only socket will connect to my siteon the page which contains the applet. I will not be trying to connect to any other domain. Does this mean I can somehow get socket network programming working without signing the applets?

The applet does not have to be signed to connect back to the server it was loaded from.

I’ve had unsigned applets connect back on port 80, so I know that works at least. I have a vague memory of hearing something about other ports not working.

So If I have 2 people who open the same page and load the same applet, one hosts on port 80 and the other joins to getCodeBase().getHost(), on port 80 it will work?

eg Server:
serverSocket = new ServerSocket(80, 10);
clientSocket = serverSocket.accept();

and Client:
clientSocket = new Socket(getCodeBase().getHost(),80);

will this work? can you give me some example code?
does anyone know which ports you can use and which ones you can’t?
thanks

Well, the one hosting on port 80 won’t be sitting on the server I guess so in that case you’d need to sign it.

this is the thing. I will only be using sockets on my site for a game, so the only socket will connect to my siteon the page which contains the applet. I will not be trying to connect to any other domain. Does this mean I can somehow get socket network programming working without signing the applets?

yes, you can connect back to the server that deliver the applet without signing

Socket Sample : (connect to the http server that deliver the applet)

Socket s=new Socket(getCodeBase().getHost(),getCodeBase().getPort());

URL sample : (read html embedding the applet using http)

URL u = new URL(getDocumentBase());

Sorry I’m getting confused because of the mixed comments

I tried port 80 and it didnt even let me host on that port.

if the person who opens the applet and hosts on port 80, is there any way to use the ip of the website as theirs instead of their own so i dont have to sign it?

Do you mean the server of my site which hosts my webpage?
or a person who opens my applet and hosts from that

[quote]Do you mean the server of my site which hosts my webpage?
[/quote]
this one

An unsigned applet can’t open serversockets, it can only connect to others.

So as long as I have a signed server applet, I dont have to sign the client applets?

They can only connect back to the server hosting the applet, not to anyone else playing on the same site[*].

[* well, unless they’re playing locally from the web server]

Roland,
If you have your socket server hosted in the same place you hosted your applet, the clients don’t need to be signed .

If you have the server socket anywhere else different than the place you applet is hosted, the clients need to be signed .

If you want a player to be a server (e.g. host a game) both the host and the client party must be signed (the server side need to be signed to open a server socket, the client side need to sign because it will connect to somewhere different than the place you applet is hosted)

If you can achieve to do it like the first situation, but still want people to be able to create their “game rooms” , a workaround would be the gamerooms to be actually created in your server, not in the players machine . That will, by the way, prevent people from modifying their local server and cheat - because the logic would be running in your secure distant server . Just like a Starcraft game in Battle.net and stuff .

thanks for the info, teletubo
I guess I will have to sign them then as I cannot host a server on my website :’(
So if 2 people each load the same applet, one hosts and one joins, how can I stop them cheating?

Hosting on a website (or more precisely on some server/VPS) is better as it works nicely for people who are behind NAT. Games that requires hosting on your own computer often means that the players can’t simply connect to each other, or they have to configure manually their router to do port mapping. There are some libraries (can’t find them right now) that can “punch” the NATs to allow connection between two NATed clients (or non-NATed to NATed), but they’re not 100% reliable either.

You can’t. And even with authoritative central server there are still many ways to cheat (eg. wallhacks, aimbots, etc.). In case you find someone cheating you can ban him by his IP though.

There is also an extensive discussion about this on this thread . You might find some interesting ideas for you .