www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - MSG_WAITALL for Sockets

reply "Jeroen Bollen" <jbinero gmail.com> writes:
Is there a way I can call a receive method on a socket with 
MSG_WAITALL as a flag? There doesn't seem to be an enum for that.
Nov 19 2013
parent reply "Rob T" <alanb ucora.com> writes:
On Tuesday, 19 November 2013 at 18:35:08 UTC, Jeroen Bollen wrote:
 Is there a way I can call a receive method on a socket with 
 MSG_WAITALL as a flag? There doesn't seem to be an enum for 
 that.
module core.sys.posix.sys.socket; enum : uint { MSG_CTRUNC = 0x08, MSG_DONTROUTE = 0x04, MSG_EOR = 0x80, MSG_OOB = 0x01, MSG_PEEK = 0x02, MSG_TRUNC = 0x20, MSG_WAITALL = 0x100 } Use SocketFlags to set the flag. If using Windows, you can set up your own enum, as I don't think one is pre-defined. --rt
Nov 19 2013
parent reply "Jeroen Bollen" <jbinero gmail.com> writes:
On Tuesday, 19 November 2013 at 23:36:57 UTC, Rob T wrote:
 On Tuesday, 19 November 2013 at 18:35:08 UTC, Jeroen Bollen 
 wrote:
 Is there a way I can call a receive method on a socket with 
 MSG_WAITALL as a flag? There doesn't seem to be an enum for 
 that.
module core.sys.posix.sys.socket; enum : uint { MSG_CTRUNC = 0x08, MSG_DONTROUTE = 0x04, MSG_EOR = 0x80, MSG_OOB = 0x01, MSG_PEEK = 0x02, MSG_TRUNC = 0x20, MSG_WAITALL = 0x100 } Use SocketFlags to set the flag. If using Windows, you can set up your own enum, as I don't think one is pre-defined. --rt
Thanks! I don't really get how this is working though, isn't the point of using an enum as a type, preventing any values that's not listed in the enum definition?
Nov 20 2013
parent "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Wednesday, November 20, 2013 17:26:27 Jeroen Bollen wrote:
 On Tuesday, 19 November 2013 at 23:36:57 UTC, Rob T wrote:
 On Tuesday, 19 November 2013 at 18:35:08 UTC, Jeroen Bollen
 
 wrote:
 Is there a way I can call a receive method on a socket with
 MSG_WAITALL as a flag? There doesn't seem to be an enum for
 that.
module core.sys.posix.sys.socket; enum : uint { MSG_CTRUNC = 0x08, MSG_DONTROUTE = 0x04, MSG_EOR = 0x80, MSG_OOB = 0x01, MSG_PEEK = 0x02, MSG_TRUNC = 0x20, MSG_WAITALL = 0x100 } Use SocketFlags to set the flag. If using Windows, you can set up your own enum, as I don't think one is pre-defined. --rt
Thanks! I don't really get how this is working though, isn't the point of using an enum as a type, preventing any values that's not listed in the enum definition?
SocketFlags in std.socket is used incorrectly. It's used as a parameter type for &ed values rather than just a list of the flags that you can & together, and unfortunately, the language does not currently prevent that. You can do stuff like. enum Foo : string { a = "bar" } auto b = Foo.a; b ~= " stool"; with impunity. It's just that the compiler will prevent something like Foo f = "hello"; So, the type protection on enums is currently quite poor. IMHO, the compiler should prevent an enum from ever having an invalid enum value when no casts are used, but that's just not the way that it is right now. Pretty much all it protects against are direct assignments. And I have no idea whether that will ever be fixed or not. Hopefully it will be though. - Jonathan M Davis
Nov 20 2013