This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Separating two continuous message from the client  RSS feed

 
saumil baxi
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a Server/Client architecture. When the client send two message back to back to the server, it gets read at the same time.
below is my code which is reading from the inputStream



So now when the client sends "Hi" and "Hello" as two different messages, both messages are read at the same point.

Any way I can separate two message?

Thanks,
Saumil
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. That is a really ghastly way to build a String from individual bytes.
2. What is your message terminating character? People have used various control characters for this purpose, such as line feed or eof.

Bill
 
Andrey Kozhanov
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe before sending second message your client should wait for some reply from your server. I.e. you should organize some dialog between your client and server.
 
saumil baxi
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply,
I agree it is not the best way to read the inputstream,
But the problem is the protocol between the client and the server is fixed and two separate people are implementing server and client , moreover client can send a multiple request simultaneously to hang the server and its upto the server to handle it.

So I can neither add the end tag nor can send out of order message to the client.

Thanks,
Saumil
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you don't have a protocol which allows you to separate two messages which are sent consecutively, then no amount of hacking with code will allow you to separate the two messages.

So if the protocol is "fixed", and people are now starting to write clients and servers and finding serious errors like that, now would be the time to stop programming until a workable protocol is designed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!