On Tuesday 13 Jul 2010 20:09:16 Alessandro Salvatori wrote:
>     shouldn't it say "continue" instead of "return 0" if you fail binding
> the current random port attempt?

The zero return status indicates success; we return if we hit a bind success.

> why do we do 65536 attempts? it seems kind of arbitrary to me, given they
> are all random attempts...

The initial attempt is random; subsequent attempts increment by one.  The 
logic is to try up to all of the available 65536 ports (excluding any below 
1024), but to use a random starting port to minimise the chance of reusing the 
same port on consecutive boot attempts.

Michael

Reply via email to