I'm trying to read a response from a server and BufferedReader.readline will block and never return.
If I run the exact same code from the command line on my Linux host it works, but it will hang when run on my emulator or device. Here's the code try { System.out.println("will call socket!"); mysocket = new Socket(hostname, portno); System.out.println("Connected to " + mysocket.getInetAddress() + " on port " + mysocket.getPort() + " from port " + mysocket.getLocalPort() + " of " + mysocket.getLocalAddress()); DataOutputStream os = new DataOutputStream(mysocket.getOutputStream()); DataInputStream is = new DataInputStream(mysocket.getInputStream()); BufferedReader d = new BufferedReader(new InputStreamReader(is)); if (mysocket != null && os != null && is != null) { os.writeBytes(command + "\r\n"); String line; System.out.println("calling readline after command:" + command); line = d.readLine(); System.out.println("got: " + line); return line; } } catch (UnknownHostException e) { ... What I see on android is: I/System.out( 644): will call socket! I/System.out( 644): Connected to /192.168.1.109 on port 4998 from port 52695 of /10.0.2.15 I/global ( 644): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required. I/System.out( 644): calling readline after command:getversion D/dalvikvm( 98): GC freed 2313 objects / 133904 bytes in 67ms W/KeyCharacterMap( 644): No keyboard for id 0 W/KeyCharacterMap( 644): Using default keymap: /system/usr/keychars/ qwerty.kcm. On Linux (OpenJDK) I get what I expect: Connected to /192.168.1.109 on port 4998 from port 33097 of / 192.168.1.104 calling readline after command:getversion got: 710-1001-04 getversion returned: 710-1001-04 Any ideas? Is the BufferedReader different on Android? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en