This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes Separating two continuous message from the client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply locked New topic

Separating two continuous message from the client

saumil baxi
Ranch Hand

Joined: Apr 18, 2008
Posts: 58
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()];;
str = str + new String(b);

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?

Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42958
Please do not post the same question to multiple forums: CarefullyChooseOneForum

Let's continue the discussion in this duplicate thread.
Have you checked out Aspose?
subject: Separating two continuous message from the client
It's not a secret anymore!