c++linux

where is socket header in linux


I compile my simple prog with #include <sys/socket.h> but there's none of this file. Where is it, I just start coding in linux and I have no idea where is it . Or do we need to download it online .


Solution

  • In case you have installed manual pages, the first stop should be man socket.

    Without manual pages you could call

    find /usr/include -name socket.h
    

    which outputs

    /usr/include/asm/socket.h
    /usr/include/sys/socket.h
    /usr/include/bits/socket.h
    /usr/include/linux/socket.h
    

    on my system, the one to include is sys/socket.h .

    Also see the Single UNIX Specification.