what does 0 indicate in socket() system call?

后端 未结 3 2146
旧时难觅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

    As others have likely said, the third argument to socket is generally an int indicating the protocol. 0 indicates that the caller does not want to specify the protocol and will leave it up to the service provider.

    Other than zero, another common one is IPPROTO_TCP.

    Full details can be found on the man page using man 2 socket on your machine or visiting here.

提交回复
热议问题