30#include <netinet/in.h>
35int main(
int argc,
char** argv) {
36 int sock = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
38 printf(
"Couldn't get a socket: %d [%s]\n", errno, strerror(errno));
45 struct timeval timeout = {.tv_sec = 30, .tv_usec = 0};
48 FD_SET(sock, &readfd);
50 int ready = select(sock + 1, &readfd, 0, 0, &timeout);
54 printf(
"select failed: %d [%s]\n", errno, strerror(errno));
61 int n = read(sock, tmp,
sizeof(tmp));
63 printf(
"interface received %d bytes\n", n);