Unix domain sockets (UDS, AF_UNIX) in System.inheritedChannel() and elsewhere in Java + [JDK-8231187] + [JDK-8231358]
František Kučera
franta-java at frantovo.cz
Mon Sep 23 14:20:25 UTC 2019
In response to: <https://bugs.openjdk.java.net/browse/JDK-8231187> and
<https://bugs.openjdk.java.net/browse/JDK-8231358>
> Best to ask František to argue his approach on nio-dev. The concern
with his approach is that it converts the local/remote address to an
IPv4 address, makes it looks like the socket is bound or connect to the
wildcard address.
Would be the 127.0.0.1 better? However I agree that this is not optimal
(this was intended as a hotfix changing minimum amount of code).
> More generally, ServerSocketChannel and SocketChannel aren't
appropriate channels to return because of the specified socket options
and half close semantics. It would require specification changes to
allow ServerSocketChannel and SocketChannel be channels for other types
of listener and stream-oriented channels.
I have successfully tested it with Jetty and Tomcat – they were able to
listen on an inherited unix domain socket (I can connect to them e.g.
using the socat command or Apache HTTPD configured as a reverse proxy).
But again, I agree that using inet channels for other than inet
connections is bad. This was the reason why I suggested adding real
support for unix domain sockets:
<https://mail.openjdk.java.net/pipermail/net-dev/2019-July/012908.html>.
I wish unix domain sockets became first class citizens in Java (the
channel and address interfaces are generic enough and prepared for such
extension).
> This bug needs to be fixed independent of any future work to define
new channel types for Unix domain.
Agree, but please fix it in a backward compatible way.
> Would be useful to support a public API to AF_UNIX socket channels
for both connection sockets and listeners. Also, provide hook into
SelectorProvider.inheritedChannel.
Agree.
> Need to verify support in Windows, whether the new AF_UNIX sockets
can be multiplexed with existing networking sockets
Latest Windows versions have support for AF_UNIX, but they will probably
require different native C code than the network sockets (while on unix
systems the C code is almost the same).
Franta
More information about the nio-dev
mailing list