java.nio and SelectionKey.interestOps(int i)

Martin Kihlgren zondolfin at
Sun Jan 18 15:45:46 PST 2009

Hello list!

I have this problem that I thought maybe you could help explaining.

I have this application, where a server thread loops around a
select(), and then does stuff to the different SelectableChannels that
pops out from the Selector.

If something is read from a channel, for example, I send it to a
handler. And if the handler wants to respond in some way, it adds it
to a queue and then does interestOps(interestOps() &
SelectionKey.OP_WRITE) on its SelectionKey. Then it does wakeup() on
its Selector.

In Sun's java 6 for linux, this works beautifully. The Selector wakes
up, does another select, and finds that suddenly this
SelectableChannel wants to be (and can be) written to.

In SoyLatte, however, nothing happens! No matter if I wake the
selector up one or many times, it doesn't recognize that the
SelectableChannel and its SelectionKey is interested in OP_WRITE.

Any ideas?

//Martin Kihlgren

More information about the bsd-port-dev mailing list