I have figured out how to check if the port is open or not in my server.
However, I am facing an issue that how to check the numbers of other devices listening to the specific port.
My flow of application is:
First, my application will check if my server's port is open or not.
Second, if the port is open, it will need to check the number of devices listening to the TCP port.
Third, if port reach specific number, lets say 20 devices listening to the TCP port, I will need the application to listen to following port for port availability.
Can someone enlighten me about this case?
There was never any mystery about that. Just try to connect to it.
The server is listening to the port. The devices are connected to it.
In other words your application connects to the port.
Why?
Why?
There is no such thing as 'limit specific number of device in a port'. You can have many thousands of simultaneous connections to the same TCP port. Web servers do this 24 hours a day.
Using a single port does not cause congestion or 'bad traffic', and using multiple ports where you could have used one just wastes resources at the server.
There is no point in this. It is based on a serious misunderstanding of TCP.