Use WSAIoctl.
According to SIO_RCVALL Control Code,
The socket handle passed to the WSAIoctl or WSPIoctl function must be one of the following:
- An IPv4 socket that was created with the address family set to AF_INET, the socket type set to SOCK_RAW, and the protocol set to IPPROTO_IP.
- An IPv6 socket that was created with the address family set to AF_INET6, the socket type set to SOCK_RAW, and the protocol set to IPPROTO_IPV6.
The socket also must be bound to an explicit local IPv4 or IPv6 interface, which means that you cannot bind to INADDR_ANY or in6addr_any.
See the rcvall example.