Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   urgent question (http://www.go4expert.com/forums/urgent-question-t806/)

slammer 17May2006 19:27

urgent question
Hi ,
I want to write a client server program that has 2 clients and a server
o The server generate 10 random integers and put it in a Jlist.

o If a client read an integer then he will not be able to read the next one until the other client read 1 integer.

o After each client read 5 integers he submit the total to the server ( a textFeild in the interface).

o The server verify that the total of all generated integers is equal to the sub totals submitted by clients.

So, can any one give me some hints to solve this problem ????

shabbir 17May2006 22:52

Re: urgent question
Client server communications can be established in lots of way and the best of the lots are

1. Piped communications
2. Socket communication

Piped communications details can be foundin the java docs at http://java.sun.com/docs/books/tutor...edstreams.html

Amit Ray 18May2006 10:17

Re: urgent question
Though you did not mention which area you need help with - I mean the technology part .. or the implementation or the actual algorithm .. I will mention few things which came to my mind.

It seems from the statement of your problem once the reading is initiated by a client it knows the indices in the JList from which to read the numbers; i.e. the client which starts reading the number will read the : 1st, 3rd, 5th, 7th and 9th numbers while the other will read 2nd, 4th .... 10th number.

The client can intimate the server through simple messages (consider JMS - The java messaging framework) when it has read a number and the server in turn can intimate the other client.

An easier way would be to maintain the client ID, its read status, and the actual number read in a DB / file; obviously the server will do this with feedback from the client.

Once the clients return the corresponding sums, the verification can be done easily by the sever. Infact if you maintain the individual numbers read, you can go one step further and check whether each client has done its job correctly.

Hope that helps.

slammer 20May2006 17:56

Re: urgent question
thank you very much "Amit Ray" , I think what you said so far is enough for solving my problem I'll try to write the numbers to a file and let the clients to have them from it.

All times are GMT +5.5. The time now is 01:52.