title: Connection refused when using abstract namespace unix sockets
body: <p>I have a strange problem with unix socket (US) using so-called abstract namespaces when using Python and "pure" C (Python 3.x but looks like 2.x have the same problem).
  "Normal" socket works like a charm. With "abstract" one US my code works only when I'm using same "code platform" (C or Python).</p>
  
  <p>First I thought it has something to do with <code>memset</code> / <code>str(n)cpy</code> (see <a href="https://stackoverflow.com/q/30818410/5512967">Can not connect to an abstract unix socket in python</a>) but imho it's not that case.</p>
  
  <p>Test matrix (srv - server, cli - client):</p>
  
  <ul>
  <li>srv + cli @ "abstract" unix sock:
  
  <ul>
  <li>python + python = OK</li>
  <li>c + c = OK</li>
  </ul></li>
  <li>srv + cli @ "normal" unix sock:
  
  <ul>
  <li>python + python = OK</li>
  <li>c + c = OK</li>
  </ul></li>
  <li>srv + cli @ "normal" unix sock:
  
  <ul>
  <li>python + c = OK</li>
  <li>c + python = OK</li>
  </ul></li>
  <li>srv + cli @ "abstract" unix sock:
  
  <ul>
  <li>python + c = FAIL [cli / strace output: ECONNREFUSED (Connection refused)]</li>
  <li>c + python = FAIL [cli / raised exception: socket.error: [Errno 111] Connection refused]</li>
  </ul></li>
  </ul>
  
  <p><code>/proc/net/unix</code> / <code>lsof</code> or <code>strace</code> show nothing unusual:</p>
  
  <ul>
  <li><p>working "normal" socket C client:<br>
  <code>// ...</code><br>
  <code>socket(PF_LOCAL, SOCK_STREAM, 0)        = 3</code><br>
  <code>connect(3, {sa_family=AF_LOCAL, sun_path=@"/var/tmp/sock.tmp"}, 110) = 0</code><br>
  <code>// ...</code>  </p></li>
  <li><p>misbehaving "abstract" socket C client:<br>
  <code>// ...</code><br>
  <code>socket(PF_LOCAL, SOCK_STREAM, 0)        = 3</code><br>
  <code>connect(3, {sa_family=AF_LOCAL, sun_path=@"/var/tmp/sock.tmp"}, 110) = -1 ECONNREFUSED (Connection refused)</code><br>
  <code>// ...</code>  </p></li>
  </ul>
  
  <p>Python bug or what...?</p>
  
  <p>Gist with code samples for <strong>my test matrix</strong>: <a href="https://gist.github.com/soutys/ffbe2e76a86835a9cc6b" rel="nofollow noreferrer">https://gist.github.com/soutys/ffbe2e76a86835a9cc6b</a></p>
  
  <p><strong>Original</strong> code / samples:</p>
  
  <ul>
  <li>C servers/clients - based on <a href="https://github.com/troydhanson/network/tree/master/unixdomain" rel="nofollow noreferrer">https://github.com/troydhanson/network/tree/master/unixdomain</a></li>
  <li>Python servers/clients - based on <a href="https://stackoverflow.com/q/23282635/5512967">Python 3.X Unix Socket Example</a></li>
  </ul>
  
  <h2>Update 2015-11-02</h2>
  
  <p>More info about system and compilations:</p>
  
  <ul>
  <li>host system: Ubuntu 14.04.3 LTS (x64);</li>
  <li>all C test files compiled with <code>gcc</code> (example: <code>gcc -Wall -Wextra -pedantic -o abs_cli abs_cli.c</code>);</li>
  <li>all programs (both compiled and built-in python) run as non-root user;</li>
  </ul>