I'm doing some socket programming that I'm trying to make cross-platform compatible. For Windows systems, I'm including the following headers:
#include <winsock2.h>
#include <ws2tcpip.h>
When I tried to compile my application on Windows, I got errors about the following constants' being undefined:
IP_RECVOPTS
IP_RECVRETOPTS
I thought that odd, because I thought those were pretty common socket options, but perhaps I'm wrong. Either way, sure enough, they're not listed anywhere in the Windows socket documentation.
The documentation in a Linux distro's in.h
says the following about these constants:
IP_RECVOPTS /* bool; Receive all IP options w/datagram. */
IP_RECVRETOPTS /* bool; Receive IP options for response. */
In that distro's in.h
, the defined value of the first one appears to be 6, while the defined value of the second one appears to be 7.
So, my questions:
- Are there equivalent constants in Windows sockets for replacing these two constants (or, perhaps, do I just need to include some other header)?
- If not, is the receiving of IP options even possible in Windows sockets?
- If so, is it safe for me to hard-code these values on Windows systems to 6 and 7, respectively, or should they be some other value?
UPDATE 1
I continued my Google research today. I found these two interesting tidbits. I don't know whether they help me. The first is the Windows Runtime (WinRT) Socket Address header (WinRTSockAddr.h
) from the MixedRealityToolkit
repository on Microsoft's official GitHub account. It contains the following:
#define IP_RECVOPTS 6
#define IP_RETOPTS 7
This aligns with *nix values I've seen elsewhere (I've commonly seen IP_RETOPTS
aliased to IP_RECVRETOPTS
). But then there's this alleged Windows Sockets helper header from the "Geek Research Lab"'s GitHub account. I've no idea if it has any credibility, but it has different values for these constants:
#define IP_RECVOPTS 5 /* bool; receive all IP opts w/dgram */
#define IP_RECVRETOPTS 6 /* bool; receive IP opts for response */
#define IP_RECVDSTADDR 7 /* bool; receive IP dst addr w/dgram */
#define IP_RETOPTS 8 /* ip_opts; set/get IP options */
That's contradictory on all fronts: values and the aliasing of IP_RETOPTS
to IP_RECVRETOPTS
. :-/