Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
    Bookmark Topic Watch Topic
  • New Topic

Separating two continuous message from the client

 
saumil baxi
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • 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

view plaincopy to clipboardprint?
String str = "";
while (in.available() > 0) {
byte [] b = new byte[in.available()];
in.read(b);
str = str + new String(b);
System.out.println(str);
}


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
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not post the same question to multiple forums: CarefullyChooseOneForum

Let's continue the discussion in this duplicate thread.
 
It is sorta covered in the JavaRanch Style Guide.
    Bookmark Topic Watch Topic
  • New Topic