Hi,

I am experiencing slowness connecting to a Java NIO server running in my Android app.

The server code is fairly boilerplate:

- Create a listening server socket like this:

   ServerSocketChannel channel = ServerSocketChannel.open();
   channel.configureBlocking(false);
   ServerSocket socket = channel.socket();
   socket.setReuseAddress(true);
   socket.bind(isa);


- Register it with a selector

   mMainSelector = Selector.open();
   mMainAcceptKey = mServerChannel.register(mMainSelector,
   SelectionKey.OP_ACCEPT);

- Enter a processing loop

   while (mMainSelector.select(SELECTOR_TIMEOUT) {
        .... stuff getting the selected keys ....
        SocketChannel socketChannel = channel.accept();

Problem is, it takes about 1-3 seconds from the time the client begins to connect to when the above code gets to the last line (channel.accept()).

For read/write operations, the select() call returns immediately, which is expected.

Has anyone else seen this slowness in select() when accepting new connections?

--
Kostya Vasilyev ~ WiFi Manager + pretty widget ~ 
http://kmansoft.wordpress.com/sw

--
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