Thursday, February 2, 2012

Advanced Java Program?

So i'm gonna start a Java program project. My goal is to make a chess game, that's the easier part compared to my other goal. That is to be able to connect with another person on another computer to play against. It won't necessarily be over the Web, It is at my school where everyone is connected to a server. We use macs and use OSX. I don't really want the exact code, I just want to know what kind of components am I going to need to use to achieve this. How will I be able to send information from one computer to another, more specifically what kind of class would I use. Any help would be appreciated. Thanks.Advanced Java Program?
For communication over networks it would be a good start to look into the socket classes in the Java networking API.



Java provides Socket and ServerSocket which allows programs to communicate with each other.



You would need to set up a ServerSocket on each computer hosting the game, providing a port to run the service on. Then on the client PC you can create a Socket to connect to the service, providing the IP address of the server and the port number it is running on.



java.sun.com provides some good tutorials for working with sockets so would be a good place to start.Advanced Java Program?
what do you need is..a client server architecture

client will run on each players desktop and server will be running on some machine on your school network.



you (client) will connect to server inititating a game request with another user a normal handshaking process will be done in order to start a game

then each move will be sent across to each player and server maintains the session between the players.



for all this concept to get actually working you need to learn java's Socket and ServerSocket class.

and the most important thing you need to learn and implement the multithreaded enviroment here to support multiple players session running on the server.

No comments:

Post a Comment