views:

144

answers:

2

If I use send() on a non-blocking tcp socket in Linux will it return EAGAIN for anything other than a send buffer full condition?

I basically need to decide if I want to use the socket send buffer as the only buffer for my app or if I need my own user space buffer to feed the socket buffer.

+1  A: 

It shouldn't but I don't see how that affects your decision about a user space buffer one way or another. Either you'll need a buffer or not depending on what your app is doing, regardless of the specific reason for getting an EAGAIN.

You can also think about changing the tcp buffer size with setsockopt with the SO_SNDBUF option after doing some calculations to see if it is actually a performance win or not.

Duck
A: 

If I use send() on a non-blocking tcp socket in Linux will it return EAGAIN for anything other than a send buffer full condition?

On non-blocking socket that should be only condition, as send() blocks only when the send buffer is full.

Otherwise, I would suggest not to depend on the behavior as in my experience EAGAIN sometimes returned when something minor fails in kernel, yet socket is still OK. I had recently the experience on HP-UX when EAGAIN was returned since apparently kernel was running low on memory. As error is recoverable, EAGAIN is acceptable error code for the case.

Dummy00001