Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Java network programming

Posted on 2004-08-27
13
189 Views
Last Modified: 2010-03-31
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
0
Comment
Question by:cpa199
  • 4
  • 4
  • 4
  • +1
13 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 11913138
0
 
LVL 6

Expert Comment

by:expertmb
ID: 11913193
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11913196
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 50 total points
ID: 11913202
You can broadcast to the clients by keeping a client list at the server and sending to them all
0
 
LVL 35

Accepted Solution

by:
TimYates earned 75 total points
ID: 11913206
> 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
 
LVL 1

Author Comment

by:cpa199
ID: 11913619
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
 
LVL 35

Expert Comment

by:TimYates
ID: 11913720
> 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
 
LVL 1

Author Comment

by:cpa199
ID: 11913757
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
 
LVL 86

Expert Comment

by:CEHJ
ID: 11913790
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
 
LVL 35

Expert Comment

by:TimYates
ID: 11913847
Yeah, sorry...you can just have the clients stored in the server and notify them via callbacks
0
 
LVL 1

Author Comment

by:cpa199
ID: 11913873
Well whatever I know what I need to do now, and that is just to use callbacks. Cheers.

Carl
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 11913983
?

Thanks anyway ;-)
0
 
LVL 1

Author Comment

by:cpa199
ID: 11914292
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

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Application launch issue with Apache Tomcat 5 64
ForLoop Example 3 52
tomcat administrtor 12 61
Eclipse for Java EE development 2 27
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to implement Singleton Design Pattern in Java.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question