pschichtel/JavaCAN

Implement NIO Channel

pschichtel opened this issue · 3 comments

Instead of having a custom Socket-like class, implement SelectableSocket, so we get all the existing Java APIs for free, including epoll based select on linux.

This could also use:

  • ByteBuffer (see #1)
  • NetworkInterface
  • SocketOption

These could reduce the amount of required native code required on my side and reuse what the JVM already provides.

DatagramChannel is probably a good reference for the implementation.

This will require the implementation of the internal interface sun.nio.ch.SelChImpl in order to reuse the existing native selectors. This in turn also requires the use of sun.nio.ch.IOUtil.newFD(int) or Reflection to create a FileDescriptor instance from an existing file descriptor.

it is currently not possible to implement SelectableChannel to work with any Selector, because the APIs to expose the internal socket filedescripter are all private (sun.nio.ch.*), which Java 9+ won't link against.

Now implemented in master