views:

218

answers:

3

im developing a multi-player card game that needs the clients to communicate with each other or a general server. i have never done this before so i need some direction or tutorial on how to achieve this.

so far i have created the local, single person version of the game...

+4  A: 

Sun has a good tutorial on writing a client/server pair complete with code examples.

Asaph
thank you! that should work well..
Ali
as a followup... if i were to pass object back/forth to another objects (lets say passing Card objects to Dealer object), would I have to use serialization?
Ali
@Ali: Definitely, although if you're to write your own protocol you may just send some identifiers like AS ( for Ace of Spades ) or 1H ( 1 of hearts ) and skip the serialization process.
OscarRyz
+1  A: 

So far i have created the local, single person version of the game...

Great, I would suggest to continue with the local multi-player version of the game ( even when it is controlled by the same "terminal" )

From there you may explore RMI to invoke the methods remotely. It should be much more simpler than creating the multi-player version and add networking.

What RMI does is to abstract the network connectivity and allow you to simplify the execution of remote objects call ( that is, it simplifies having to write your own protocol with sockets )

OscarRyz
whoaaa i hadnt even heard of this... this does seem a whole lot simpler.. in reference to my comment above about serialization, would RMI be a simpler way of accomplishing this?
Ali
Actually they go together. By writing your own protocol ( as the above answer suggest ) you may decide to use serializable objects or not. The *problem* ( or the opportunity ) is that you would also have to code the instructions to invoke methods in the other side of the wire, and send back the results. With RMI ( which stands for Remote Method Invocation ) you don't need to code the logic to call a method or get the results back from the client to the server, you just call them. About the serialization it is fairly simple in general terms ( you just implement `Serializable` interface )
OscarRyz
A: 

RMI is more complex. You need to understand some concepts before starting with RMI, like extending Remote, RemoteExceptions, etc. And also, running applications powered by RMI require some steps, such as starting rmiregistry, and setting a policies file.

If you are a beginner, start with simple sockets first. They are easier to understand, but somewhat long to code. RMI is easier to code, but somewhat tough to understand.

For Sockets:

TCP Sockets

UDP and Datagrams

For RMI:

Simple tutorial to RMI - Really helped me start

Inf.S