aspose file tools
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
Register / Login


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

Separating two continuous message from the client

saumil baxi
Ranch Hand

Joined: Apr 18, 2008
Posts: 58
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
Marshal

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

Let's continue the discussion in this duplicate thread.


Android appsImageJ pluginsJava web charts
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Separating two continuous message from the client
 
Similar Threads
File outputted has size zero
Client/server - message getting delayed..
Separating two continuous message from the client
working with the DataBase
Data loss converting StringBuilder to byte[]?