Java on a Server

Hey everybody.

I'm working on a little turn-based game and I hope to learn a bit about networking in the process by making it multi-player.

The only problem with that is that I know next to nothing about networking. As I understand it, I have to have a server that each instance of the game connects to so that they can communicate -- one game sends a message to the server, the server forwards it to everyone who needs to hear it.

That's about all I know -- except a bit on the technicals of sockets because I read up on those.

I don't have a clue how to make a server run a java program or what sort of parameters I should be giving to the socket constructors to establish a connection.

This stuff has been bugging me for a while. Any help would be greatly appreciated.

-Neal

[823 byte] By [Nialsha] at [2007-11-27 7:58:30]
# 1

two great resources would be the javadocs and this delicious website: www.javaalmanac.com (which is now called exampledepot or something)...

Search for ServerSocket or just socket connections and similar buzz words... They have GOOD WORKING EXAMPLES!

Note: I advise sending datagrams rather than single flushes of information.

For the actual structure of your program I recommend having any player or user to have the ability to start a server. After starting a server, that user automatically begins running a client program which uses the server program that he just ran. WHY? because now ur life is easier cuz u dont have to give the server user special code... So talk to us when u know more about sockets... javaalamanc.com is REALLY helpful, so check that out to learn the networking fundementals... GOOD LUCK!!!!

ArikArikArika at 2007-7-12 19:40:25 > top of Java-index,Other Topics,Java Game Development...
# 2

Looks like good stuff and thanks for the advice.

I was under the impression that you can't have a socket connection straight from one applet to another applet for security reasons. What you're suggesting then changes the game from a browser game to an application.

I can deal with that for simplicity during development but I'd like the final product to be a browser game.

Thanks for the help.

Nialsha at 2007-7-12 19:40:25 > top of Java-index,Other Topics,Java Game Development...