Alex Rivera | Logout

Is there any difference between IPv4 and IPv6 at the socket level?

Asked 2010-03-01T15:38:36.380
11

I need to add IPv6 support to an existing socket-based application which currently only supports IPv4. To embrace the incoming era of IPv6, someone ordered me to add an IPv6 interface for the app and let the outside world to choose either the IPv4 interface or the IPv6 interface when trying to communicate with the app.

My question is: is it true that for the socket handling API level in Linux, there is no difference between handling an IPv4 based socket and IPv6 based socket?

Further more, is it possible to let a socket listen on two IP addresses with same port? If that is true, then to implement the requirement is a trivial work, I guess.

Edit
Report

1 Answer

3

Beej's Guide to Network Programming addresses the differences in coding for IPv4 and IPv6. http://beej.us/guide/bgnet/

He has dedicated one section to changing your existing IPv4 code to handle IPv6.

He also explains how to code abstractly at the socket level so that you do not need to know whether or not you are dealing with an IPv4 address, or an IPv6.

answered 2010-03-06T08:39:06.477

Your Answer