As far as I have observed,both libs consist of over 90% same exact codes.
When I declare them in my example programs,no magic happens.
I don’t really understand the difference of those libs even though they are located in seperated directories.Can someone break it down for me?
Plus:
I tried declaring linux/in.h above sys/socket.h ,the complier buzzed like “cannot find specified-qualified-list for sa_family_t”,which means sa_family_t is not defined in the scope of linux/in.h,if called in this manner…
Then I tried same thing for netinet/in.h,well,it works regardless of places the declaration are.
The
linux/*.hheaders were really meant for internal kernel use and if Linux were being created today, these files would not even exist under/usr/include. But early on, a lot of the userspace libc (libc4 and libc5 at the time) relied on Linux headers to define types, constants, structures, etc. for use in userspace, sonetinet/in.hcontained just#include <linux/in.h>or similar, and the lovely tradition got started. Today the only headers in thelinuxtree that should be used for userspace apps are some things related to supporting specific hardware at a low level, like the Linux console, framebuffer, video4linux, etc.In short, you should use
netinet/in.h(the standard header specified by POSIX) and pretend you never sawlinux/in.h. 🙂