• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Question about page 488 of Head First Java

 
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hiya! buddies. How's everything in the Ranch?
Have a nice happy and safe Halloween!
Leaving the ghostly matters aside I have a question concerning sockets and threads.
There's an exercise in the Head First book, it's about making a chat application, but in page 488 I don't understand the explanation given for not using Option number 2. It says:

Option Two: Read something in from the server each time the user sends a message.



--The book states that this option shouldn't be considered because it's an arbitrary time to check for messages.

Could someone explain me Why is it arbitrary? --because I would have done exactly as suggested in option 2.

And more Importantly,
I don't understand

Option 3: Read messages as soon as they're sent from the server



How exactly is option 3 different from Option 2?

I don't quite get it. *Help Me

I anticipate my most sincere gratitude for all you time.

Sincerely,
Jose
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the wording is perhaps a bit misleading. "User" refers to the local client I assume, and in which case if you only read from the server when the local client sends a message then you would only ever know if the remote client in the chat has said anything once you say something.
 
Jose Campana
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings...
Sorry, umMmMmM,

I'm still not gettin' it. What's wrong with me?

If someone could contribute to help me understand this little part, please let me know what you think.

Sincerely,
your friend, Jose
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So option two says that I will retrieve everyone elses messages when I MYSELF send a message.

Option three says that I will retrieve everyone elses messages when THEY send a message.

Imagine if your IM client of choice didn't tell you what the person you're talking to said, until you sent them a message. It would be very difficult to have a conversation, and the reason it's arbitrary is because you may type a message every second, or every century.
 
Jose Campana
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey Adam.!
Thank you very much... I've got it.
That's the clarification I just needed..

Keep on your excellent work ! You don't know how much I appreciate it ! But it's really a lot.

Thank you fellow java programmer.

Sincerely,
Jose
 
Heroic work plunger man. Please allow me to introduce you to this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic