socket_sendall clearly gives up once send() returns -1, which it will do (with errno of EAGAIN or EWOULDBLOCK) if you call it on a non-blocking socket without calling poll() or select(). (And the internal_select function skips calling poll()/select() when the socket is non-blocking.)