title: Linux: what happens when binding on port 0
body: <p>What happens when I try to <code>bind(2)</code> on port 0 (linux 5.0) ?</p>
  
  <p>Using BSD nc: <code>nc -l 0</code> works, and stracing it gives me:</p>
  
  <pre><code>bind(3, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
  listen(3, 1)                            = 0
  accept4(3, 
  </code></pre>
  
  <p>But trying to connect : </p>
  
  <pre><code>$ nc 127.1 0
  nc: port number too small: 0
  </code></pre>
  
  <p>What happens here ?</p>