I am running two instances of stunnel in Windows 7, configured to listen to the same port, and it appears that they are both successfully listening on the same port (just using socket()/bind()/listen()). Both instances appear to succeed with all calls and they show up in a netstat:
C:\>netstat -ano | grep 8000
TCP 0.0.0.0:8000 0.0.0.0:0 LISTENING 5828
TCP 0.0.0.0:8000 0.0.0.0:0 LISTENING 5852
The first one to listen gets all incoming requests.
This is pretty much opposite to all my expectations. (I was expecting to get EADDRINUSE telling me the port was busy.) So....
- Why/How does this work? Is this behavior useful in some context?
- I don't want an instance to successful run if another application is going to catch the incoming requests... How do I make the port exclusive?