gpt4 book ai didi

sockets - D 中的 MSG_WAITALL 标志

转载 作者:行者123 更新时间:2023-12-03 11:52:11 26 4
gpt4 key购买 nike

有没有办法在 D 中使用 MSG_WAITALL 标志调用 Socket 上的 receive() ?我检查了来源,但似乎没有它的枚举。

最佳答案

看起来 phobos 没有定义它,但 druntime 定义了它,所以你可以将值转换为 SocketFlags:

// on posix
import core.sys.posix.sys.socket;
receive(buffer, cast(SocketFlags) MSG_WAITALL);

// on windows
receive(buffer, cast(SocketFlags) 0x08 /* MSG_WAITALL, number found on msdn */);

这有点骇人听闻,但是如果您查看源代码,您会看到标志在传递到低级别 recv 时刚刚被转换回 int。无论如何,所以它应该可以正常工作。

关于sockets - D 中的 MSG_WAITALL 标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20079995/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com