title: domain socket fragmentation
body: <p>I am using domain sockets (AF_UNIX) to communicate between two threads for inter process communication. This is chosen to work well with libev: I use it on the recv end of the domain socket. This works very well except that the data I am sending is constant 4864 bytes. I cannot afford to get this data fragmented. I always thought domain sockets won't fragment data, but as it turns out it does. When the communication is at its peak between the threads, I observe the following</p>
  
  <pre><code>Thread 1:
  SEND = 4864 actual size = 4864
  
  Thread 2:
  READ = 3328 actual size = 4864
  
  Thread 1:
  SEND = 4864 actual size = 4864
  
  Thread 2:
  READ = 1536 actual size = 4864
  </code></pre>
  
  <p>As you can see, thread 2 received the data in fragments (3328 + 1536). This is really bad for my application. Is there anyway we can make it not fragment it? I understand that IP_DONTFRAG can be set to only AF_INET family? Can someone suggest an alternative?</p>
  
  <p>Update: sendto code</p>
  
  <pre><code>ssize_t
  socket_domain_writer_dgram_send(int *domain_sd, domain_packet_t *pkt) {
  
      struct sockaddr_un remote;
      unsigned long len = 0;
      ssize_t ret = 0;
  
      memset(&amp;remote, '\0', sizeof(struct sockaddr_un));
      remote.sun_family = AF_UNIX;
      strncpy(remote.sun_path, DOMAIN_SOCK_PATH, strlen(DOMAIN_SOCK_PATH));
      len  = strlen(remote.sun_path) + sizeof(remote.sun_family) + 1;
  
      ret = sendto(*domain_sd, pkt, sizeof(*pkt), 0, (struct sockaddr *)&amp;remote, sizeof(struct sockaddr_un));
      if (ret == -1) {
          bps_log(BPS_LOGGER_RD, ASL_LEVEL_ERR, "Domain writer could not connect send packets", errno);
      }
      return ret;
  }
  </code></pre>