title: Unix domain socket file still present after closing it
body: <p>This is what I'm trying in <code>ghci</code> (Haskell <code>REPL</code>):</p>
  
  <pre><code>&gt;&gt;&gt; import Network.Socket
  &gt;&gt;&gt; sock &lt;- socket AF_UNIX Stream defaultProtocol
  &gt;&gt;&gt; bind sock (SockAddrUnix "./test.socket")
  &gt;&gt;&gt; listen sock 5
  &gt;&gt;&gt; close sock
  </code></pre>
  
  <p>At this point <code>./test.socket</code> is in the file system refusing connections, but I'd expect that after closing a listening connection the file would also be removed. I believe this is standard Unix convention, not specific to Haskell, so what's the reason to have the file lying around after closing it?</p>
  
  <p><strong>Update:</strong> If I try to bind another socket to the same file I get an error:</p>
  
  <pre><code>&gt;&gt;&gt; sock2 &lt;- socket AF_UNIX Stream defaultProtocol
  &gt;&gt;&gt; bind sock (SockAddrUnix "./test.socket")
  *** Exception: bind: resource busy (Address already in use)
  </code></pre>
  
  <p>So if I can't rebind another socket to the file or reconnect to it because it's closed what's the point?</p>
  
  <p><strong>Update:</strong> The <a href="http://man7.org/linux/man-pages/man7/unix.7.html" rel="nofollow">man entry for <code>unix</code></a> mentions:</p>
  
  <blockquote>
    <p>Binding to a socket with a filename creates a socket in the filesystem
    that <strong>must be deleted</strong> by the caller when it is no longer needed (using
    unlink(2)).  The usual UNIX close-behind semantics apply; the socket
    can be unlinked at any time and will be finally removed from the
    filesystem when the last reference to it is closed.</p>
  </blockquote>
  
  <p>So it's expected from the user to <code>unlink</code> explicitly the socket, but that still doesn't answer my question. What's the reason to have it around if you can't do anything with the socket?</p>
  
  <p>Is my high level programming bias kicking in here? Is this kind of explicitness the norm when doing systems level programming?</p>