- Widening the Network with IPv6
- IPv6-Supporting Languages/Networks
- C Programming Changes
- Preparing Your Code Today for Tomorrow
- Gaining the IPv6 Advantage
Preparing Your Code Today for Tomorrow
Even if you don't start working on the extra features of IPv6, you can take steps now to make your code easier to change (or even transition smoothly) later. Network programming is a very challenging and important skill, so certain habits and techniques make it easier to avoid problems and enhance success:
Be careful about return values. The examples above don't check the return values for easier reading. Go to http://www.linuxsocket.org for examples of how to catch errors.
Don't assume that the user is going to give you one address or another; test it instead. While inet_pton() and inet_ntop() have a parameter for the network type, it cannot autodetect the network. You may have to do that yourself.
Note, document, and centralize the sections that may need changing later. This can save your skin over and over again. It will make your life easier (as well as the lives of those who maintain the product).