RFR 8245194: Unix domain socket channel implementation

Michael McMahon michael.x.mcmahon at oracle.com
Mon Jul 13 11:41:36 UTC 2020


INET6 effectively means IPv4 or IPv6 and the protocol family is set at 
socket creation,
before binding. So, I don't think it would be possible to do that.

Michael.

On 10/07/2020 11:33, Bernd Eckenfels wrote:
> I like the protocolFamily addition. Should it allow to differentiate 
> between IPv6 socket bound to ipv4 address or in case of wildcard bound 
> dual stack? (I sometimes had the desire in the path to see what the 
> prefer Option and network libraries closed to use, so you can for 
> example know if the listening shows up in socketstat as v4 or v6 address.
>
>
> -- 
> http://bernd.eckenfels.net
> ------------------------------------------------------------------------
> *Von:* nio-dev <nio-dev-retn at openjdk.java.net> im Auftrag von Michael 
> McMahon <michael.x.mcmahon at oracle.com>
> *Gesendet:* Friday, July 10, 2020 12:25:56 PM
> *An:* Chris Hegarty <chris.hegarty at oracle.com>
> *Cc:* nio-dev <nio-dev at openjdk.java.net>
> *Betreff:* Re: RFR 8245194: Unix domain socket channel implementation
>
>
> On 09/07/2020 15:14, Chris Hegarty wrote:
>>
>>
>>> On 8 Jul 2020, at 11:07, Michael McMahon 
>>> <michael.x.mcmahon at oracle.com <mailto:michael.x.mcmahon at oracle.com>> 
>>> wrote:
>>>
>>>> ...
>>>>
>>>> My initial reaction to seeing verbiage like "Internet protocol 
>>>> socket” and “unix domain socket”, is how does one know what type of 
>>>> socket channel one has if passed an unbound channel? I wonder if a 
>>>> SocketChannel::protocolFamily method is worth adding? It could be 
>>>> used and linked to from some of the verbiage elsewhere to tighten 
>>>> the spec. There could also be some tie in here with 
>>>> inheritedChannel - if the protocol family is retrievable.
>>> I did consider that question and had concluded that testing the type 
>>> of the SocketAddress returned by getLocalAddress() would suffice for 
>>> this. But, you're right that does not work for unbound channels. 
>>> I'll add this to the API for now (for SocketChannel and 
>>> ServerSocketChannel in the sandbox), to see what it looks like. 
>>> Perhaps, for consistency it should be added to DatagramChannel too?
>>
>> That works for me.
>>
>> What is the signature of this method? `Optional<ProtocolFamily> 
>> protocolFamily()` - or something else? If not optional ( or null ), 
>> then what is the family of a channel created with the no-args open 
>> method? We had some offline discussion about UNSPEC, and if we add 
>> this method then it could be a reason to add an UNSPEC 
>> StandardProtocolFamily.
>>
> "public ProtocolFamily getProtocolFamily()"
>
> I think a channel will always have a ProtocolFamily. So, it shouldn't 
> need to be Optional<>
>
> The value on the no-args call depends on the preferIPv4Stack setting. 
> INET if set INET6 if not,
> depending on which of IPv4/IPv6 are supported obviously. Do you think 
> all of this would need
> to be documented explicitly?
>
> Michael
>
>> -Chris.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20200713/03f10698/attachment.htm>


More information about the nio-dev mailing list