Qn on POSIX header files

why do books state to #include <sys/types.h> when I'm using socket when it simply works fine when I just #include <sys/socket.h>

btw, what does <sys/un.h> and <sys/in.h> stand for?
Because sys/socket.h is gratuitously including the things you need from sys/types.h.
For portability's sake, you must include sys/types.h also, as the gratuitous inclusion
is not mandated/required by any standards.

sys/un.h: UNIX protocol family related types/functions.
sys/in.h: Inet protocol family related types/functions.
what about unistd.h?
Always observe the manual pages. If they say that you should #include specific headers to use a function or structure, then do it. Otherwise you don't need to.
Topic archived. No new replies allowed.