Client/server-communication in Texas Hold'em
I am currently programming a Texas Hold'em LAN game in Java. My problem is how to do the client/server-communication.
Each time something happens at the table, the clients need to be inform开发者_运维知识库ed of this so they can repaint their GUIs. Also when a players turn is up, they need to be able to fold, call etc.
How do I best implement this? I've looked at callbacks/RMI, but from what I've read, that may cause problems with firewalls(?)
When you are concerned about firewalls, the best way would be to use HTTP, like a web browser. The benefits are:
- The protocol is well-known
- There are many client and server libraries available, which are well-tested
- HTTP is not restricted to web browsers. Any program can talk HTTP.
The downside is that push messages by the server are not commonly used. Of course you can just open an HTTP connection from each client that will wait for data from the server.
I would suggest the Java tutorials on sockets:
http://download.oracle.com/javase/tutorial/networking/sockets/
An example client/server is given.
精彩评论