what does 0 indicate in socket() system call?

后端 未结 3 2143
旧时难觅i
旧时难觅i 2021-02-09 06:46

what 0 indicates in following line? what are other flags i can use?

server = socket(AF_UNIX, SOCK_STREAM, 0)
3条回答
  •  野性不改
    2021-02-09 07:08

    From the man pages of socket:

    int socket(int domain, int type, int protocol);
    

    The protocol specifies a particular protocol to be used with the socket. Normally only a single protocol exists to support a particular socket type within a given protocol family, in which case protocol can be speci‐ fied as 0. However, it is possible that many protocols may exist, in which case a particular protocol must be specified in this manner. The protocol number to use is specific to the “communication domain” in which commu‐ nication is to take place; see protocols(5). See getprotoent(3) on how to map protocol name strings to proto‐ col numbers.

提交回复
热议问题