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 <[email protected]> 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 [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

Reply via email to