Thanks, is this better?
There are different things I don't understand complete. How does the receive buffer affect the output buffer in this case? Isn't it possible to disable non-blocking sockets in vis.c:635-638 and change the read to following for json: Try to recv data until the read fails or an empty line (please check HTTP rfc before implementing) appears. If the read fails -> discard everything. If the empty line appeared then send the data. You should create an extra function to read (and discard) the header stuff.
My personal opinion about the errno and delay stuff is... I don't like it. It seems to be somewhat correct to ask again on EAGAIN corresponding to the man page, but we could do it in a cleaner way if possible.
Maybe someone sees a problem in my proposal. The only thing I see is that the read should appear before locking the current buffer or a "bad person" (me) could delay the new buffers for all others by connecting and then wait for a long time. I see the same problem in your current implementation.
Regards, Sven