try {
input = new BufferedReader(new InputStreamReader(
mSocket.getInputStream()));
while (!Thread.currentThread().isInterrupted()) {
String messageStr = null;
messageStr = input.readLine();
if (messageStr != null) {
updateMessages(messageStr, false);
} else {
break;
}
}
input.close();
} catch (IOException e) {
Log.e(CLIENT_TAG, "Server loop error: ", e);
}
I am using the above code in a thread for receiving responses from socket connection.
In Android it works correctly as I used out.println()
for sending data, but when the device is connected to ios and starts to receive data it cannot identify the end and is only received when the connection is closed. Is there any alternative methods other than readLine()
and how to use in the above code.