使用 MSG_WAITALL 发送的套接字得到 22 EINVAL

Socket send with MSG_WAITALL got 22 EINVAL

bool AbstractSocket::send(void *data, const size_t &size)
{
    ssize_t result = ::send(m_sfd, data, size, MSG_WAITALL);
    if (result == -1 ) {
        if (errno != EAGAIN) {
            LOG_ERR("failed to write socket")
            emitErrorSignal();
        } else { // else If errno == EAGAIN
            // that means we have read all data.
            return true;
        }
    } else if (result == 0) {
        // The remote has closed the connection
        LOG_WNG("the remote has closed the connection")
        emitErrorSignal(std::errc::connection_aborted);
    }
    return size == static_cast<size_t>(result);
}

我正在尝试创建一个指定大小的发送函数来发送所有数据。 为什么 send 引发 EINVAL 错误?哪个参数无效?

What argument is invalid?

send 函数没有 MSG_WAITALL 选项。所以 MSG_WAITALL 是无效的。

send仅支持:

  • MSG_EOR
  • MSG_OOB

https://linux.die.net/man/3/send