I have a server application which uses permanently connected incoming ports within the range that W2k8 now uses in the IANA recommended range of ~49000-65000. (For legacy reasons it's extremely difficult to change this, so I'm going to have to change Window's range to avoid my range, but that's not the question).
I've been researching how to avoid conflicts with ephemeral ports in Windows 2008 Server, but can't find details on the Windows algorithm for selecting ephemeral ports.
When the Windows network layer is assigning a 'random' ephemeral port for the response to an outgoing TCP/IP connection, does it test the proposed port to see if it's being used already?
(The Linux kernel seems to do a check_established test but could still re-use some used connections, so I'm wondering what decisions Windows might make in taking seemingly unused or idle ports off another process...)
i.e. if my server opens winsocks on all its ports, and keeps them in LISTENING state, will Windows respect and skip over them because they're in use? Or will it ignore the fact they're in use, and assign them to other processes anyway for ephemeral use, causing conflicts?
I have found that sometimes when my server starts it cannot allocate a few of its ports, because they're being used for random purposes by other processes - which makes sense and I understand that. But I haven't yet been able to prove if ports it does manage to initially open are subsequently 'stolen' for ephemeral purposes (it's a difficult thing to test or force due to the large range and random nature).
As I said, I am going to reconfigure windows to avoid my server anyway, so this question is more out of curiosity and to explain recent behaviour more clearly (to rule in/out other possible bugs!)
thanks in advance