android - read end of response in java readLine() -
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 using above code in thread receiving responses socket connection.
in android works correctly used out.println()
sending data, when device connected ios , starts receive data cannot identify end , received when connection closed. there alternative methods other readline()
, how use in above code.
this work better.
try { input = new bufferedreader(new inputstreamreader(msocket.getinputstream())); string messagestr = ""; while (!thread.currentthread().isinterrupted() && (messagestr = input.readline()) != null) { updatemessages(messagestr, false); } input.close(); } catch (exception e) { log.e(client_tag, "server loop error: ", e); }
Comments
Post a Comment