Given a socket handle, is there any way to determine if it is AF_INET or AF_INET6, e.g. first parameter to create socket(https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-socket)? I am programming on Windows.
CodePudding user response:
getsockopt function:
int getsockopt(
[in] SOCKET s,
[in] int level,
[in] int optname,
[out] char *optval,
[in, out] int *optlen
);
If optname parameter is SO_PROTOCOL_INFO, buffer should contain WSAPROTOCOL_INFO structure. It's iAddressFamily member will be AF_INET or AF_INET6.
