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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -