tls_write() on a blocking fd. The loop for tls_write() is similar to write() while (len > 0) { ssize_t ret; ret = tls_write(ctx, buf, len); if (ret == TLS_WANT_POLLIN || ret == TLS_WANT_POLLOUT) continue; if (ret < 0) { // if (errno == EAGAIN || // errno == EINTR) // continue; err(1, "write: %s", tls_error(ctx)); } buf += ret; len -= ret; }