DatagramChannel

Alan Bateman Alan.Bateman at oracle.com
Mon Apr 16 09:52:52 PDT 2012


On 16/04/2012 14:49, Salter, Thomas A wrote:
>
> [I'm not sure if I should post this to net-dev, nio-dev or something 
> else, so I posted to both.]
>
> I have a trivial DatagramChannel program that fails on Windows if run 
> with Java.net.preferIPv6Addresses=true.  The exception and code are 
> included below.
>
> The problem is that when the bind parameter is null, 
> DatagramChannelImpl calls new InetSocketAddress(0), but that returns 
> an AF_INET6 address when preferIPv6Addresses=true.  Even when the 
> caller passes a SocketAddress to bind, it's hard to get it right if 
> you want to specify the any address or the loopback address.  The 
> methods to get these addresses all change their behavior based on the 
> setting of preferIPv6Addresses.
>
>
Just to confirm that this duplicates on Solaris and Mac too. We'll need 
to change the bind method so that the null case uses 
InetAddress.getByName("0.0.0.0") when the DatagramChannel is connected 
to an IPv4 socket. I'll create a bug for this.

-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20120416/78458b66/attachment.html 


More information about the nio-dev mailing list