Changes in Socket Bind

MSDN finally has the "Using SO_REUSEADDR and SO_EXCLUSIVEADDRUSE" doc online. I previously posted it on this blog but the formatting came out a bit funky. Here's the link:

We've received some feedback on the article saying it doesn't explicitly spell out all the changes in socket bind behavior. The tables in the doc do describe all the various combinations and their results but here are a couple key differences:

  1. To bind two sockets to the same address and port, the first socket bound to the address and port *must* set SO_REUSEADDR to indicate it will allow others to hijack it -- this requirement is new. The second socket still needs to set SO_REUSEADDR which is the same behavior as before.
  2. Without setting any options it is possible for two sockets to be bound to the same address and port. If the first socket binds to the wildcard address and port X (e.g. another socket may come along and bind to an explicit address and port X (e.g. In this case, the first socket is now listening on port 5150 for every local interface except Note: This is only true if both sockets are created under the same user context.

--Anthony Jones (ajones)

Comments (0)

Skip to main content