title: Datagram Unix domain socket with Boost.Asio
body: <p>I'm struggling to receive data with a synchronous client code that is using datagram Unix sockets with Boost.Asio.</p>
  
  <p>The server seems to be working fine because if I connect to it with <em>netcat</em> I receive data. However, when trying with the code below, it gets stuck in receive_from(). <em>strace</em> shows that the receive_from() system call is called but nothing is received, while <em>strace</em> on the server shows that is trying to send data to the client but it is failing to do so.</p>
  
  <pre><code>boost::asio::io_service io_service;
  
  boost::asio::local::datagram_protocol::socket socket(io_service);
  socket.open();
  
  cmd::cmd cmd;
  cmd.type = cmd::cmdtype::request;
  cmd.id = cmd::cmdid::dumptop;
  
  boost::asio::local::datagram_protocol::endpoint receiver_endpoint("socket.unix");
  
  /* The server receives this data successfully */
  socket.send_to(
      boost::asio::buffer(reinterpret_cast&lt;char*&gt;(&amp;cmd), 
      sizeof(cmd)),
      receiver_endpoint
  );
  
  boost::array&lt;char, 128&gt; recv_buf;
  boost::asio::local::datagram_protocol::endpoint ep;
  
  /* When the server sends data, nothing is received here.
     Maybe it's an issue with the endpoint??? */
  size_t len = socket.receive_from(
      boost::asio::buffer(recv_buf), ep);
  </code></pre>