I am running my program on Solaris. Do I need to configure my machine to run a socket program using IPV6 APIs. Are the IPV6 APIs backward compatible? for eg can I use AF_INET6 for both the protocols IPV4 n 6 ?
Asked
Active
Viewed 198 times
1
-
[This answer](http://stackoverflow.com/questions/5861107/5863101#5863101) might be helpful – mpontillo May 03 '11 at 22:06
1 Answers
2
No, you cannot set an OS option to control that behavior. The application code has to be specifially written to use the IPv6 APIs and differentiate between IPV4 and IPv6 connections.
No, the IPv6 APIs are not backwards-compatible. AF_INET is specific to IPv4, and AF_INET6 is specific to IPv6. However, many of the IPv4 API functions and structures were updated to support IPv6, and some new API functions and structures have been introduced that support both protocols in a more agnostic manner.

Remy Lebeau
- 555,201
- 31
- 458
- 770
-
..So do you mean to say that if I want to apply changes to my code to support IPV4 and 6 as well then I should put a if else condition there – Kundan Kumar May 04 '11 at 20:47
-
1In some places, yes. On the other hand, depending on what platform(s) you are targetting, IPv6 may or may not even be installed, so you should dynamically load the relavant IPv6 API functions when needed, and update your code to make use of the newer version-agnostic functions when available. For example, use the newer `getaddrinfo()` function instead of the older `gethostby...()` and `getaddrby...()` functions, and use the `SOCKADDR_STORAGE` struct instead of `sockaddr_in` and `sockaddr_in6` directly. – Remy Lebeau May 05 '11 at 06:44