networking · beginner · ~15 min
Identify the IP address families.
Tell whether an address family is one of the IP families.
Implement int is_inet_family(int af).
af: an address-family constant (e.g. AF_INET, AF_INET6, AF_UNIX).Return 1 if af is AF_INET or AF_INET6, else 0.
is_inet_family(AF_INET) -> 1
is_inet_family(AF_INET6) -> 1
is_inet_family(AF_UNIX) -> 0
af: an address-family constant.
1 if af is AF_INET or AF_INET6, else 0.
AF_INET and AF_INET6 are IP families; AF_UNIX is not.
#include <sys/socket.h>
int is_inet_family(int af) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.