thanks for reply. It's not an IP problem, my real device and client computer are all connected to local network through a WIFI router, they can connect to each other directly. My phone has IP address: 192.168.0.176 and computer's IP is 192.168.0.126, assigned by DHCP.
I found that if I establish any connection from my phone to computer before I start to listen on port, then my phone could be successfully noticed that there're incoming connections and of course, accept them. Why it has this strange network connection behavior? thanks a lot On Sat, Jun 26, 2010 at 1:27 AM, social hub <shubem...@gmail.com> wrote: > > do you know what's the ip address you got on the real device. > > There are chances the real device is on NAT network. In such a case you > wont be able to talk directly to the device. > > > On Fri, Jun 25, 2010 at 12:04 PM, Alex Xin <xinxi...@gmail.com> wrote: > >> more on this problem... >> >> it works great in emulator, but always failed on real device >> >> >> On Sat, Jun 26, 2010 at 1:03 AM, Alex Xin <xinxi...@gmail.com> wrote: >> >>> Hi, folks >>> >>> I'm now facing a very strange server socket problem, I have a server that >>> will listen on a TCP port, I use the following code to do this work. >>> >>> public class RequestListenerThread extends Thread { >>> >>> private final ServerSocket serversocket; >>> >>> public RequestListenerThread(int port, final String docroot) >>> throws IOException { >>> this.serversocket = new ServerSocket(port); >>> setDaemon(true); >>> } >>> >>> public void run() { >>> Log.v("FE", "SMB Server Listening on port " >>> + this.serversocket.getLocalPort()); >>> >>> while (!Thread.interrupted()) { >>> try { >>> // Setup incoming client connection >>> Socket socket = this.serversocket.accept(); >>> Log.v("FE", "Incoming connection from " >>> + socket.getInetAddress()); >>> // Start worker thread >>> Thread t = new WorkerThread(socket); >>> t.start(); >>> } catch (InterruptedIOException ex) { >>> break; >>> } catch (IOException e) { >>> Log.v("FE", "Network I/O error: " >>> + e.getMessage()); >>> break; >>> } >>> } >>> } >>> } >>> >>> My target device is running on Android 1.6. >>> >>> When I run this code, it can start to listen on port but can't accept any >>> incoming connections. When it runs into serversocket.accept function, it >>> never return, just like dead lock. >>> >>> Does anybody has the same issue? How do you solve this problem? >>> >>> Thanks very much >>> >>> Alex >>> >> >> -- >> 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<android-developers%2bunsubscr...@googlegroups.com> >> For more options, visit this group at >> http://groups.google.com/group/android-developers?hl=en >> > > -- > 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<android-developers%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- 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