Find out AF_UNIX + SOCK_SEQPACKET maximum message size

Hy, I wonder if there is an opportunity to find out the maximum length of SEQPACKET, except for experimental (a-la for (i = 0; i <100 ... 00; i ++) send (...))).

And, the second question:

If I received errno == EMSGSIZE trying to send AF_UNIX SEQPACKET, is this guaranteed due to the maximum message size, or could there be some other reasons?

Sorry for my English.

+4
source share
1 answer

The limit comes from the sysctl_wmem_default variable. It is available for viewing in the proc file system: /proc/sys/net/core/wmem_max

In this case, different versions of Linux may have different implementations. But there is code for UNIX domain sockets:

 sk->sk_sndbuf = sysctl_wmem_default; 

and

 err = -EMSGSIZE; if (len > sk->sk_sndbuf - 32) goto out; 

So the actual limit is: / proc / sys / net / core / wmem _max minus 32 . I do not know how much this magic number varies between versions. The value of / proc / sys / net / core / wmem _max seems to depend on the available ram pages.

In my linux field, the value is 105472. And the maximum size of the datagram (when using AF_UNIX and SOCK_DGRAM) is 105440. If I try to send a message of size 105441, it will fail with EMSGSIZE.

+5
source

All Articles