07-18-2024, 11:21 AM
Hi,
I am looking for a clean way to make a service search for available ports to open it and listen on that port and then set the chosen port number in the Windows registry for clients to use to connect to it, whether it is using TCP or UDP. Is there a function out of the box for Indy to use, or do I need to do this the hard way and loop through random numbers starting from specific numbers and keep going up until I find an open port?
Currently, What I am doing is that I get the process ID and then adding 8000 to it and use that as the port number for the service, but I want a cleaner way to do so.
I am looking for a clean way to make a service search for available ports to open it and listen on that port and then set the chosen port number in the Windows registry for clients to use to connect to it, whether it is using TCP or UDP. Is there a function out of the box for Indy to use, or do I need to do this the hard way and loop through random numbers starting from specific numbers and keep going up until I find an open port?
Currently, What I am doing is that I get the process ID and then adding 8000 to it and use that as the port number for the service, but I want a cleaner way to do so.