java - Sockets receiving null (Android) -


I have an Android app that is communicating with a server (written in Java). I have established a socket connection between these two parts and want to send the data. The problem I am facing is that sometimes, for some users, the information reaching the server is zero.

This works (for all phones, all users):
Server:

  int a = integer ParseInt (in.readline ()); Int b = integer Parasont (in.readline ()); Int c = integer Parasont (in.readline ()); Int D = Integer. ParisInt (inlineline ()); String checksum = in.readLine (); String model = in.readLine (); String device = in.readLine (); String name = in.readLine ();  

Customer:

  Out.printLine (A); Out.println (b); Out.println (c); Out.println (d); Out.println (hash); Out.println (Build.MODEL); Out.println (Build.DEVICE); String Name = Fixx (); Out.print (name); Out.flush ();  

This does not work (for some users):
Server:

  int a = integer ParseInt (in.readLine ()); String checksum = in.readLine (); String model = in.readLine (); String device = in.readLine (); String name = in.readLine (); String msg = in.readLine (); Int version = -1; String test = "hedge"; Try {test = in.readLine (); Version = integer Parasont (test); } Hold (exception e) {e.printStackTrace (); }  

Customer:

  Out.printLine (A); Out.println (hash); Out.println (Build.MODEL); Out.println (Build.DEVICE); String Name = Fixx (); If (name == faucet) name = "John do"; Out.println (name); String msg = fixMsg (); If (msg == null) name = "nada"; Out.println (MSG); Out.println (curversion); Out.flush ();  

Sometimes, in the second case, the name, message, and version (string test) are zero on the server side. The catch is starting because the test is zero.
The response, the one, are the remaining string

Any thoughts?

poor coding here. Every time you call readLine (), you must immediately check the result for the tap, and if the truth will stop reading and closing.

This is a job for special status scanner


Comments