0

Given a socket(AF_UNIX, SOCK_DGRAM, 0), what is the maximal guaranteed datagram size in bytes that can be sent without receiving EMSGSIZE or any other error number related to invalid message. Another requirement is that this message would be sent atomically, meaning that it will not be split, forcing the receiver of such message to stitch it from parts.

I am looking for a constant that is defined by the POSIX standard, and I wasn't able to find it so far.

Daniel Lovasko
  • 471
  • 2
  • 10

1 Answers1

0

There is no guarantee. Linux has OS config parameters, net.core.{r,w}mem_max, my box has them at the distro default, 208KB. Read /proc/sys/net/core/rmem_max etc. to see the limits. For really high-bandwidth ipc you want something like a shared memory ring buffer anyway, no need to go through the OS for every message, only to wake the other end up if it's gone idle waiting for buffers.

DGRAM messages are always sent whole, there's no such thing as segmentation on AF_UNIX (aka AF_LOCAL) (since it's entirely inside the box). If you don't supply a big-enough receive buffer the remainder will likely just be dropped.

jthill
  • 55,082
  • 5
  • 77
  • 137