Java network programming

I have never done any network programming in Java before now, and need to know just some basics or theory really.
I am planning to write a small hearts card game in my spare time for 4 players over a network, very much like the old network MSHEARTS game.
My question is how I should go about the networking for this. I am going to create it as a client/server app, with the dealer the server and 3 clients joining to play. Should I use RMI or sockets? If I were to use RMI (which I would like to give a go if possible) how can I broadcast information back to the clients, as I believe that the objects are all server side with remote information on clients which makes it very simple for clients to interact with the server but how do I go the other way, for example tell a client it is their go next or broadcast to all for a new round?

Many thanks

Carl Austin
LVL 1
cpa199Asked:
Who is Participating?
 
TimYatesCommented:
> but how do I go the other way

I think the clients will have to poll the server to see if they have any messages waiting them...
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
TimYatesCommented:
This is quite cool:  It was written for a book on J++, but isn't J++ specific :-)

http://www.lantimes.com/ltparts/connect/shoptalk19.htm
0
 
CEHJCommented:
You can broadcast to the clients by keeping a client list at the server and sending to them all
0
 
cpa199Author Commented:
Seen all the tutorials before, but thanks for the links anyway, these are simple at best and just explain a little about how to access a method of a remote object on a server (for RMI). What I need is to know how to go server to client, and I think that Tim has it right when he says that the clients will have to poll the server.
0
 
TimYatesCommented:
> and I think that Tim has it right when he says that the clients will have to poll the server.

It will also mean that you only have one possible firewall issue (client -> server) rather than two (server -> client) ;-)
0
 
cpa199Author Commented:
Yup, but infact your post led me to think, and of course I could use RMI callback to send out information from the server, especially seeing as firewall isn't an issue to start with. Once I have it done I will improve stuff like that and then even add my own computer based players! That will be the tricky part.

Carl
0
 
CEHJCommented:
I don't understand Tim's comment. This was (part of) your question:

>>how can I broadcast information back to the clients

How does polling come into this?
0
 
TimYatesCommented:
Yeah, sorry...you can just have the clients stored in the server and notify them via callbacks
0
 
cpa199Author Commented:
Well whatever I know what I need to do now, and that is just to use callbacks. Cheers.

Carl
0
 
CEHJCommented:
?

Thanks anyway ;-)
0
 
cpa199Author Commented:
It is because you both in a way prompted me to look for the right things and I found out what I needed, so no problem.

Carl
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.