Hello, you are trying to connect to "localhost" which is the emulator. Please try the name or IP address of your physical machine!
Best regards, Christian -----Ursprüngliche Nachricht----- Von: [email protected] [mailto:[EMAIL PROTECTED] Im Auftrag von Isuru Gesendet: Mittwoch, 12. November 2008 05:19 An: Android Beginners Betreff: [android-beginners] data communication between emulator and localhost i want to communicate data between localhost( as server) and emulator (as client). server program is written using java and its running on the java flatform. Client program is written using android.we use below code for the client. try { InetAddress serverAddr = InetAddress.getByName ("localhost"); Log.d("TCP", "C: Connecting..."); Socket socket = new Socket(serverAddr, 8080); String message = "Hello from Client"; try { Log.d("TCP", "C: Sending: '" + message + "'"); PrintWriter out = new PrintWriter( new BufferedWriter ( new OutputStreamWriter(socket.getOutputStream())),true); out.println(message); Log.d("TCP", "C: Sent."); Log.d("TCP", "C: Done."); } catch(Exception e) { Log.e("TCP", "S: Error", e); } finally { socket.close(); } } catch (Exception e) { Log.e("TCP", "C: Error", e); } But it shows below error. 11-12 09:11:37.647: DEBUG/TCP(234): C: Connecting... 11-12 09:11:37.647: ERROR/OSNetworkSystem(234): unknown socket error -1 11-12 09:11:37.678: ERROR/TCP(234): C: Error 11-12 09:11:37.678: ERROR/TCP(234): java.net.SocketException: unknown error 11-12 09:11:37.678: ERROR/TCP(234): at org.apache.harmony.luni.platform.OSNetworkSystem.createSocketImpl (Native Method) 11-12 09:11:37.678: ERROR/TCP(234): at org.apache.harmony.luni.platform.OSNetworkSystem.createSocket (OSNetworkSystem.java:79) 11-12 09:11:37.678: ERROR/TCP(234): at org.apache.harmony.luni.net.PlainSocketImpl2.create (PlainSocketImpl2.java:59) 11-12 09:11:37.678: ERROR/TCP(234): at java.net.Socket.startupSocket(Socket.java:668) 11-12 09:11:37.678: ERROR/TCP(234): at java.net.Socket.<init> (Socket.java:215) 11-12 09:11:37.678: ERROR/TCP(234): at mili.android.DataCom.TCPClient.run(TCPClient.java:20) 11-12 09:11:37.678: ERROR/TCP(234): at java.lang.Thread.run (Thread.java:935) 11-12 09:11:37.916: INFO/ActivityManager(50): Displayed activity mili.android.DataCom/.SocketTest: 913 ms 11-12 09:11:37.968: INFO/ARMAssembler(50): generated scanline__00000077:03545404_00000A04_00000000 [ 29 ipp] (51 ins) at [0x23f4c0:0x23f58c] in 7832686 ns 11-12 09:11:43.007: DEBUG/dalvikvm(89): GC freed 2452 objects / 123016 bytes in 78ms --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Beginners" 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-beginners?hl=en -~----------~----~----~----~------~----~------~--~---

