1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

urgent question

Discussion in 'Java' started by slammer, May 17, 2006.

  1. slammer

    slammer New Member

    Joined:
    May 17, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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 ????
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
  3. Amit Ray

    Amit Ray New Member

    Joined:
    Jul 12, 2004
    Messages:
    75
    Likes Received:
    4
    Trophy Points:
    0
    Occupation:
    Software Developer
    Home Page:
    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.
     
  4. slammer

    slammer New Member

    Joined:
    May 17, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    hi
    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.
     

Share This Page