This approach is fraught with problems for picking a port. How do you pick a random port that doesn't collide with an existing port in use? How do you prevent another application from acquiring that port between the time you pick the random port (and check that it is free) and the time you actually listen on it? I've hit both of these problems in practice.
Specifying port 0 should be allowed and it should result in the OS picking the port which is far safer (though in rare cases I've seen this fail as well).
After all, port 0 was designated for this.
-- Mike
Specifying port 0 should be allowed and it should result in the OS picking the port which is far safer (though in rare cases I've seen this fail as well).
After all, port 0 was designated for this.
-- Mike