• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Error with Client and Server using Socket

 
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm working on a message server to client but somehow i'm not getting any reply from either message
here part of the code


and the other


noreply.PNG
[Thumbnail for noreply.PNG]
 
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi jin,

Not sure if you want to make a chat server or echo server but below are my findings:

In Server code, below part sends message to client:


But, at client side, the code is reading that line, printing it and breaking while(true) loop (first inner loop) only if that message is stop or end. However, that message is 'Whatcha want?'. Thus, loop will not break, and client is waiting for another message from server.
Meanwhile, server is also waiting for another message from client:


I think at client side, if the message (from server) is not end/stop, then you should give client a chance to send a message to server.

I hope this helps.
 
jin Otanashi
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anayonkar Shivalkar wrote:Hi jin,

Not sure if you want to make a chat server or echo server but below are my findings:

In Server code, below part sends message to client:


But, at client side, the code is reading that line, printing it and breaking while(true) loop (first inner loop) only if that message is stop or end. However, that message is 'Whatcha want?'. Thus, loop will not break, and client is waiting for another message from server.
Meanwhile, server is also waiting for another message from client:


I think at client side, if the message (from server) is not end/stop, then you should give client a chance to send a message to server.

I hope this helps.


thank you so much for the explanation now the program is working fine. ( the program does reply the server and client )
reply
    Bookmark Topic Watch Topic
  • New Topic