title: ECONNREFUSED on datagram Unix socket
body: <p>What are the possible reasons for ECONNREFUSED when sending over a connectionless datagram Unix socket?</p>
  
  <p>Also any advice on how to debug this is welcomed as this problem is reproducible.</p>
  
  <p>I get the error regardless if <code>sendto()</code>or <code>sendmsg()</code> is used.</p>
  
  <pre><code>if ((sock = socket(PF_UNIX, SOCK_DGRAM, 0)) &lt; 0)
  {
      return 0;
  }
  unlink("/tmp/serv");
  addr.sun_family = AF_UNIX;    
  
  strncpy(&amp;addr.sun_path[0], "/tmp/serv", sizeof(addr.sun_path));
  
  if (bind(sock, (struct sockaddr *)&amp;addr, sizeof(addr)) &lt; 0)
  {
      return 0;
  }
  
  sockaddr_un from;
  int fromlen = sizeof(from);
  if (recvfrom(sock, &amp;i, sizeof(i),0,(sockaddr*)&amp;from,(socklen_t*)&amp;fromlen) &lt; 0 )
  {
      //some error handling code
  }
  
  printf("from.sun_family=%d, from.sun_path=%s",from.sun_family,from.sun_path); // this prints, as expected "from.sun_family=1, from.sun_path=/tmp/client"
  strncpy(&amp;addr.sun_path[0], "/tmp/client", sizeof(addr.sun_path));
  sendto(sock,"abc",3,0,(sockaddr*)&amp;addr, sizeof(addr)); //this fails with ECONNREFUSED
  </code></pre>