I am searching for some information.
I have seen in many programmes following files included
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
I want to know more what the above header files are used for i.e. in which conditions which header file is used.
Any link which clearly mentions which header file serves what purpose that will be great.
If you want to know what’s in a header file, try looking at it, seriously: most will start with some comment describing the content if it’s not obvious anyway.
If you want to know what part of a header file is being used by the program that’s including, try removing it and looking at the error messages. That may also sound glib, but sadly there’s generally not a better way to find this out. But, it may be that on one platform some functionality requires including two headers, whereas on some other platform only one of them is required (perhaps because the second header is indirectly picked up by some earlier include anyway): if you test on the platform where one header is needed and decide to remove the second include, you may break the build on the other platform. So, when you find stuff that is needed, consult the man pages for the required headers – they may be specified by some Standard that both platforms honour.
If you want to know which header files to use yourself, then again – you have to look at the documentation for the functions you need to call. Even then, as a C++ programmer you should prefer the C++ versions of certain C headers, and standard documentation tools like
man– given the C function name – won’t tell you about the C++ headers. Have a read of e.g. http://gcc.gnu.org/onlinedocs/libstdc++/manual/bk01pt01ch03s02.html – it’s GCC documentation but describes C++ Standard requirements for these headers.