문제

Is there a way to call receive() on a Socket with the MSG_WAITALL flag, in D? I checked the source but there does not appear to be an enum for it.

도움이 되었습니까?

해결책

Looks like phobos doesn't define it, but druntime does, so you can cast the value to 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 */);

this is a bit hackish, but if you look at the source, you can see the flags is just casted back to int when passed to the low level recv anyway, so it should work without a problem.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top