2

I have generic network nonblocking socket library on Java, on default JVM all works fine, but on Android platform next code blocks :

DatagramChannel channel;
. . .
channel.bind(...)
channel.configureBlocking(false);
. . .
channel.register(udpSelector,  SelectionKey.OP_READ | SelectionKey.OP_WRITE);

Blocks on register(), execution can be blocked for 20-40 sec or forever, same only with OP_READ or only with OP_WRITE.

Any hint how to fix ?

Edit : same problem on Android 2.3 and Android 4.0.4

0

1 Answer 1

1

This is a duplicate question. Please see Java non-blocking IO selector causing channel register to block which states "The Selector has several documented levels of internal synchronization, and you are running into them all. Call wakeup() on the selector before you call register(). Make sure the select loop works correctly if there are zero selected keys, which is what will happen on wakeup()."

Sign up to request clarification or add additional context in comments.

1 Comment

Still block. I am trying to register channel in runtime.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.