I assume that this is handled at OS level. Haven't seen any socket APIs stating ports not to bind to.