We are still experiencing this issue in Ver 2.2. Is any one from the Android Team comments on this issue?
---------- Forwarded message ---------- From: gymshoe <[email protected]> Date: Nov 2 2008, 10:55 am Subject: Not getting expected socket errors To: Android Developers I think I have a closely related problem. I launch one emulator running a server program (with appropriate port redirections) and one emulator running a client. The client is able to successfully make connections to the server. Then I end the server program on the emulator, but do not kill the emulator. The client continues making active connections to the server emulator without the server program running!!! When I end the server program, I have made sure to close the server sockets and even verified that the server thread on the server emulator was killed using .isAlive()=false. I have also tried programming this without using any threads, but rather executing the server directly from the main activity (.onCreate()), and then finally closing the sockets and calling this.finish() to kill the server activity totally - again with no change in the problem. The client continues to make connections to the emulator... If I launch the client emulator alone, it does not make any connections. If I launch the client emulator in conjunction with a second emulator which has had appropriate port redirection (i.e. "telnet localhost 5554"; "redir add tcp:5000:7000") but has not executed the server android program, I do not get spurious connections. The problem occurs only when the server android program has been run once. Once the program has been run, it seems to stay resident on the emulator until the emulator is killed. Any insight into this bizarre behavior would be appreciated. Jim On Oct 30, 8:31 pm, [email protected] (James E. Blair) wrote: > Normally in TCP socket programming, if the remote end closes the > connection, the local program is notified by a return value (in C) or > an exception (in Java). But in Android, if I terminate the remote end > of a socket connection while transmitting data, no exception is > thrown, and no error reported. Is this a bug, or is there something > about socket programming in Android I'm missing? > Here's some sample Android code to demonstrate. If you run > $ netcat -l -p 1234 > It will receive the "test" transmissions, but if you kill netcat, the > Android app keeps running without printing a stack trace, indicating > no exception has been thrown. > Socket socket = null; > OutputStream os = null; > try { > socket = new Socket("10.0.2.2", 1234); > os = socket.getOutputStream(); > } catch (UnknownHostException e) { > e.printStackTrace(); > } catch (IOException e) { > e.printStackTrace(); > } > while (true) { > try { > Log.i("test", "test"); > os.write("test\n".getBytes()); > os.flush(); > } catch (IOException e) { > e.printStackTrace(); > } > } > And a standard Java app. If you kill netcat while this is running, > you'll receive the expected SocketException. > public class SocketTest { > private static Socket mSocket; > private static OutputStream mOS; > public static void main(String[] args) throws IOException { > try { > mSocket = new Socket("127.0.0.1", 1234); > mOS = mSocket.getOutputStream(); > } catch (UnknownHostException e) { > e.printStackTrace(); > } > while (true){ > System.out.println("test"); > mOS.write("test\n".getBytes()); > mOS.flush(); > } > } > } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

