WinSock: Dynamic Port Allocation
-
The MSDN for the WinSock bind API call states:
For TCP/IP, if the port is specified as zero, the service
provider assigns a unique port to the application with a
value between 1024 and 5000.
..
Binding to a specific port number other than port 0 is
discouraged for client applications, since there is a
danger of conflicting with another socket already using
that port number.Unfortunately it does not say when the allocated port number is released. When using this technique I always get the last port number increased by one. Does that mean that this method can only succeed up to 3976 times and will then fail? Or will the port number start again with 1024 after 5000 has been reached? In summary: Does anybody know more about this feature or have some references? Oliver