Unix domain sockets (UDS, AF_UNIX) in System.inheritedChannel() and elsewhere in Java
František Kučera
franta-java at frantovo.cz
Mon Aug 19 08:34:19 UTC 2019
Dne 23. 07. 19 v 17:46 Alan Bateman napsal(a):
> On 22/07/2019 09:16, František Kučera wrote:
>>
>> It is a stream or a datagram socket – just from different domain
>> (UNIX instead of INET or INET6) – but they work the same way. So yes,
>> when I create a stream or datagram unix domain socket e.g. in systemd
>> (parent process), I can inherit it in Java and get
>> ServerSocketChannel or DatagramChannel from System.inheritedChannel()
>> and it really works. Recently, I wrote an article about it:
>> https://blog.frantovo.cz/c/372/ – it is in Czech, but code and config
>> examples should be readable to anyone.
>>
>> :
>>
>> BTW: the inheritedChannel() JavaDoc says:
>>
>> > In addition to the network-oriented channels described, this method
>> may return other kinds of channels in the future.
>>
> Yes, we added this method in Java SE 5 with a view to supporting other
> channel types (e.g. console) in the future.
>
> I'll get back to you on the other points soon but I was curious about
> your observation that the inheritedChannel returns a channels with
> "garbage" local/remote addresses when fd 0 is a Unix domain socket.
> The bug is that the probe is missing a call to getsockname that it
> needs to check if the family is AF_INET or AF_INET6. So we should
> minimally fix that.
>
> -Alan
Hello,
can anyone tell me how to continue? I can change the code (the patch was
only proof-of-concept, fast hack) or change the design (e.g. creating a
new module instead of patching existing classes) but before I spend more
time with this task, I need to know, whether there is interest to have
AF_UNIX (AF_LOCAL) support in the OpenJDK (see the first e-mail in this
thread for what I mean by "support").
Franta
More information about the nio-dev
mailing list