Creating Raw Sockets

Lets create a raw socket in mode I, for use with the ICMP protocol. First the include files:
#include <sys/types.h>
#include <sys/socket.h>
Then creating the socket:
int s = socket(PF_NET, SOCK_RAW, IPPROTO_ICMP);
if (s == -1) {
    perror("raw socket():");
    exit(1);
}
Originally written by Valid HTML 4.01!guy keren