How do I find start listening to a port in TCP protocol within a specific range?
For an example:
Check the ports from 6001 to 7000 until you find an available one
and start listening to it when found.
when someone else tries the same, he cannot listen to the same port.
Thank you.
I found a way to perform that: