user123003
user123003

Reputation:

Should I listen for IPv6 connections on a separate port than IPv4?

I have a program that listens for connections and handles them. I am aware that many networking stacks support accepting IPv4 and IPv6 connections over the same socket/port, but I've also heard that Windows XP isn't one of those. In the interest of having the same code run well on all platforms, should I just listen for IPv6 connections on a separate port?

Upvotes: 5

Views: 2678

Answers (2)

Andrey
Andrey

Reputation: 4356

Windows XP SP2+ implements dual-stack IP architecture. That means that you can have two sockets (one for AF_INET and another one for AF_INET6 family) which are bound to the same port number. This works quite fine.

Note: if your intention was to have a single socket to handle both IPv4 and IPv6 connections then you depend on the so called dual IP layer stack architecture implemented in Windows Vista and later (in this case you'll have to disable IPV6_V6ONLY options on that socket).

Refer to Microsoft's Objectives for IP Version 6

Check also general recomendations in Application Aspects of IPv6 Transition (RFC 4038) .

PS: currently accepted answer by BiggsTRC is generally inaccurate as explained in the corresponding comments. However, if you are Ok with using two port numbers - then that answer still makes perfect sense.

PS2: I used terminology from the linked article. Not sure if any other platform uses this kind of separation between dual-stack and dual-layer terms.

Upvotes: 6

IAmTimCorey
IAmTimCorey

Reputation: 16755

If you are looking to be compatible with the XP platform, the simplest answer is to listen on two separate ports. If you want to get complicated, you could probably do OS detection and determine ports at runtime or something but that seems overly complicated when simply having two ports will solve the issue.

Here is a link with more information on IPv6 and XP:

http://msdn.microsoft.com/en-us/library/bb513665(v=vs.85).aspx

Upvotes: 0

Related Questions