Okhttp: Android: Use only IPV6 IP , when the wifi router provides both IPV4 and IPV6 addresses.

Created on 15 Sep 2016  路  3Comments  路  Source: square/okhttp

Hi,

Currently we are developing Android application with Okhttp.
We have a requirement to use only IPV6 wifi connection when the wifi rotuer provides both IPV4 and IPV6 addresses.

Currently okhttp picks wifi ipv4 ip and sends request out.

Okhttp Change:

One way to prioritize ipv6 is to fetch device ipv6 ip and create socket and bind to that ipv6 address.Hence request will go on that IP.

https://docs.oracle.com/javase/7/docs/api/java/net/Socket.html#Socket()

https://docs.oracle.com/javase/7/docs/api/java/net/Socket.html#bind(java.net.SocketAddress)

http://stackoverflow.com/questions/15673846/how-to-give-to-a-client-specific-ip-address-in-c

Is the design ok? Any other way in Okhttp?

Any option to specify address family like ipv4 vs ipv6.

Thanks
Nithin

Most helpful comment

All 3 comments

You can write your own DNS that filters out IPv4 addresses.

DnsSelector for the win.

Was this page helpful?
0 / 5 - 0 ratings