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.
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
JDK 16 has built-in support for Unix Domain Sockets. Here's an example from Oracle about using it with NIO
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With