Skip to content
Advertisement

Using Java NIO with Unix Domain sockets in non-blocking mode with selectors

Is there a way to use Unix Domain sockets with Java NIO? I want to use NIO so that I can use Selectors on it in a single thread.

I had a look at junixsocket but it only seems to support normal Sockets not NIO channels that support selectors.

Advertisement

Answer

You can use the project jnr-unixsocket,(https://github.com/jnr/jnr-unixsocket) which is the far most advanced implementation I’ve seen. It does exactely what you want : nio concepts Selectors, Channels etc

Look @ https://github.com/jnr/jnr-unixsocket/tree/master/src/test/java/jnr/unixsocket/example

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement