Thanks for sharing your implementation. Actually i’m using a counter for each socket and when it reach the max then I close it.
But the one thing I didn’t really figure is how to limit the number of socket. For our application we may have between 20-100 sockets which is variable depending of the sites.
I tried to set listen to 0 instead of 5 to stop our socket to listen for connection if reach max (100) but it doesn’t work. Client still get queue and they don’t receive a message like connection refused.
I have also try the function shutdown but I can’t restart my socket to listen.
So that could be a nub question but how do you stop your socket to listen temporaly?
May be I’m missing something but the following didn’t work for me
2 sockets left = Listen(2)
0 sockets left = Listen(0)