I use funfd to read packets from a tun socket, which is registered as an even callback function with libevent.
at first I read the first 20 bytes to check the IP header, and then read the following bytes:
Code:
nr_bytes = read(tunfd, buf, 20);
assert(nr_bytes == 20);
validate_ip(buf);
/* get the IP packet length and read the whole packet */
iphdr = (struct ip *)buf;
ip_len = ntohs(iphdr->ip_len);
iphdr_len = iphdr->ip_hl*4;
nr_bytes = read(tunfd, buf+20, ip_len-20);
if(-1 == nr_bytes) perror("readtun() failed:\n");
but for the second read, `read(tunfd, buf+20, ip_len-20)`, I get "Resource temporarily unavailable", what are potential problems? and how to deal with it?