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
You can write your own DNS that filters out IPv4 addresses.
There are potentially two things you may want to combine
1) Select the IPv6 target address e.g. https://github.com/yschimke/oksocial/blob/b24caf077223cf54e2ab26589839e5ba2205c691/src/main/java/com/baulsupp/oksocial/network/DnsSelector.java
2) Bind against a specific local network interface e.g. https://github.com/yschimke/oksocial/blob/b24caf077223cf54e2ab26589839e5ba2205c691/src/main/java/com/baulsupp/oksocial/network/InterfaceSocketFactory.java
DnsSelector for the win.
Most helpful comment
There are potentially two things you may want to combine
1) Select the IPv6 target address e.g. https://github.com/yschimke/oksocial/blob/b24caf077223cf54e2ab26589839e5ba2205c691/src/main/java/com/baulsupp/oksocial/network/DnsSelector.java
2) Bind against a specific local network interface e.g. https://github.com/yschimke/oksocial/blob/b24caf077223cf54e2ab26589839e5ba2205c691/src/main/java/com/baulsupp/oksocial/network/InterfaceSocketFactory.java