I am trying to re-write a Python library in Java. I was wondering if any java package was available which is analogous to the
select module available in Python.
I have been referred to the nio package but I was wondering if there was a slighly more similar Java implementation.
preguntado el 08 de enero de 11 a las 20:01
Not unless you are willing to write a JNI envoltorio para seleccione(2) yourself, or can find one on the 'net. (I looked briefly, and I didn't find one.) That's likely to be a fun little challenge, too, if you want to support Java's notion of an open file (e.g., to map a Java
InputStream into a Unix file descriptor).
The preferred way to do this in Java is, as you've noted, with
nio does have some restrictions, though. The biggest difference between
nio y seleccione(2), aside from the API differences, is that
nio will only multiplex over network sockets. You can't use it to multiselect open files, for instance.