• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error with Client and Server using Socket  RSS feed

 
jin Otanashi
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • 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]
 
Anayonkar Shivalkar
Bartender
Posts: 1558
5
Eclipse IDE Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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 )
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!