I've been asked a couple times about the socket option SO_EXCLUSIVEADDRUSE on Vista and especially how it relates to dual stack sockets. The following doc link describes the basic idea of this socket option:

http://msdn2.microsoft.com/en-us/library/ms740621.aspx

However, it hasn't been updated with any Vista specific behavior. We're working on updating that doc but it takes a while for the change to propagate to the web.

Vista follows the same rules as Windows Server 2003 when looking at that documentation, but what happens when using a dual stack socket? A dual stack socket is one that is created as IPv6 but then the IPV6_V6ONLY socket option is set to false. This results in the socket being bound to the same port on both the IPv4 and IPv6 stack. This mans that the security check is performed for the given port on both the IPv4 and IPv6 networking stacks. If either check fails, the entire bind request fails.

For example, a IPv6 dual stack socket is to be bound to port 5150 on the wildcard address (since it doesn't make sense to bind a dual stack socket to a specfic IP address). If SO_EXCLUSIVEADDRUSE is not set, then the bind will succeed even if there is another socket (IPv4 or IPv6) bound to a specific IP address on port 5150. This is no different what is described in the article above. However, if SO_EXCLUSIVEADDRUSE was set then if any other socket is bound to port 5150 (either IPv4 or IPv6), the bind call will fail thus indicating that you don't have exclusive access to that port.

Just as a reminder, applications should never set SO_REUSEADDR except for some very specific uses (e.g. multicasting) while servers should always set SO_EXCLUSIVEADDRUSE.

--Anthony Jones (AJones)