android do clients,
PC to do the service side (C # to write),
android fat PC client can receive the data, but the data returned by the PC android but not receiving,
Curiously, the same java socket communication code, can not receive the data down on android,
The java project to build a pc, or the code, but they can receive the data? !
try {
Socket stSocket = new Socket ("192.168.0.101", 30000);
. stSocket.getOutputStream () write (cmd.getBytes ());
stSocket.getOutputStream () flush ();.
System.out.println ("receiving ..");
BufferedReader br = new BufferedReader (new InputStreamReader (stSocket.getInputStream ()));
String rev;
rev = br.readLine ();
System.out.println ("received:" + rev);
} Catch (IOException e) {
/ / TODO Auto-generated catch block
e.printStackTrace ();
}
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Simulator simulator you want to access your computer above, then use the android built IP: 10.0.0.2,10.0.0.2 specific ip set simulator, is an alias for your computer
Reply:
You want to map a port, adb forword tcp: xxxxx tcp: xxxxx, so the job
Reply:
The reason is that the end of the service need to add return messages under "\ r \ n" android to read a line of information, just add "\ n", then the program can read java, android not. The fundamental reason is the underlying java program running under windows, android bottom in linux, newline prescribed two systems differ.
No comments:
Post a Comment