What does the send_timeout option achieve mean in inet:setopts?

The documentation for send_timeout says that

Specifies a longest time to wait for a send operation to be accepted by the underlying TCP stack. When the limit is exceeded, the send operation returns {error, timeout} .

Exactly what does “accepted by the underlying TCP stack” mean? If this send_timeout is set to 5 seconds and the send(2) syscall (I’m using Linux) does not return under 5 seconds, then {error, timeout} will be returned from the gen_tcp:send/2 call?

My problem is that I get {error, timeout} errors from a WebSocket connection (implemented with gun) and my traces indicate that this error happens 5 seconds after I tried to send a WebSocket frame. This error happens fairly regularly, but not easily reproducible (for example it didn’t happen in the past hour but happened nearly every minute in the hour before that). Could increasing the sndbuf size solve this issue?

gen_tcp uses non-blocking I/O, so the send call will never hang. However it will return EAGAIN, and the docs is referring to how long it takes from that you call gen_tcp:send to when the data is consumed by send without returning EAGAIN.

Yes.