I wonder if there is any possibility to find out the max length of SEQPACKET
except 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 it guaranteed that it's because of max message size, or could there be some other reasons?
Limit comes from variable sysctl_wmem_default
.
It is viewable in the proc filesystem: /proc/sys/net/core/wmem_max
Different Linux versions may have different implementation in this point. But there is this kind of 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: value of /proc/sys/net/core/wmem_max minus 32. I don't know how much this magic number changes between version. Value of /proc/sys/net/core/wmem_max seems to vary depending of available ram pages.
In my linux box the value is 105472. And maximum datagram size (when using AF_UNIX and SOCK_DGRAM) is 105440. If I try to send message with size 105441, it will fail with EMSGSIZE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With