Developing a C++ Server with Java platform. Stack with some little problem. Hope anyone can help here
C++ Server code fragment
// Sample send a socket
sned(ConnectedSocket, classroomlist, strlen(classromlist), 0);
In Java Client
// Catch the socket
InputStreamReader isr = new InputStreamReader(socket.getInputStream());
char[] buffer = new char[3];
And the problem come here
If I use BufferedReader, Nothing read out.
And I try to use
while((x = inr.read(buffer)) != -1){}
, stack into the while loop while reading. ( Discover why no output for BufferedReader )
And I try to
while(true){ SYstem.out.println(inr.read(buffer)) }print out all the length of each round of reading. Problem found! Output Like this vvvvvvvvvvv05-31 11:35:09.934: D/@@@(3264): 3 05-31 11:35:09.934: D/@@@(3264): 3 05-31 11:35:09.934: D/@@@(3264): 3 05-31 11:35:09.934: D/@@@(3264): 2
InputStremaReader.read() suppose return -1 if the tcp package reach the end.
But the function just stack beforn the end and waiting waiting waitinggggggg.