java games
on excite, yahoo and other sites there are applets that allow people to play chess and other games against each other on the internet. I'm new to java and would like to know what the best technique is to facilitate the communication between applets on different machines all over the world allowing someone in ny to play chess pretty much in real time against someone in say california. Thanks.
You can't directly access other computers with applets so you need an intermediate server:
+ user 1
|
|
server--+ user 2
|
|
+ user3
user1 can communicate with user 2 and 3 by sending a message to the server which sends the message to users 2 and 3 and so on. These messages could have a sort of pattern in them which separates different types of messages (in chess: update_my_positions, talk_to_other_player etc) from each other -> this way you get a protocol.
The connection user X -> server and server -> user X can be realised with sockets -- check the API docs of the class java.net.Socket and the networking tutorial: http://java.sun.com/docs/books/tutorial/networking/index.html
By the security definitions of Applets they are not allowed to talk to each other which is why you must go via the server. You should note that Applets are not always the best way to go, you might also want to look at Servlets and JSP and then pick the best technology for what you want to do.