The TCP/IP service providers may support SOCK_RAW type of the socket. There are two types of such sockets: the first one assumes known protocol type as written in IP header, the second one allows any protocol number. An example of the first type of socket is ICMP, an example of the second type would be an experimental protocol which is not supported by the service provider.
If TCP/IP service provider supports SOCK_RAW sockets for the AF_INET family, the corresponding protocol(s) should be included in the list returned by WSAEnumProtocols. The ipProtocol field of the WSAPROTOCOL_INFO structure may be set to 0 if the service provider allows an application to specify any value for the protocol parameter for the socket, WSASocket and WSPSocket functions.
Note An application may not specify zero (0) as the protocol parameter for the socket, WSASocket, and WSPSocket functions if SOCK_RAW sockets are used.
The following rules are applied to the operations over SOCK_RAW sockets:
It is important to understand that SOCK_RAW sockets may get many 'unexpected' datagrams. For example, a PING program may use SOCK_RAW socket to send ICMP echo requests. While the application is expecting ICMP echo responses, all the other ICMP messages (like ICMP HOST_UNREACHABLE) may be delivered to this application also. Moreover, if several SOCK_RAW sockets are open on a machine at the same time, the same datagrams may be delivered to all the open sockets. An application must have a mechanism to recognize 'its' datagram and to ignore all the others. Such mechanism may include inspecting the received IP header, using unique IDs in the ICMP header (ProcessID, for example), etc.