To programmatically access the maximum value, you can use IPEndPoint.MaxPort as well as IPEndPoint.MinPort for the minimum value. They are useful for verifying that the port that the user enters is within the correct bounds before actually trying to use it in the connection.
source
share