af_inet:指定地址族(Address Family),这里表示使用IPv4地址。 sock_stream:指定套接字类型(Socket Type),这里表示使用面向连接的TCP套接字。 0:通常指定为协议(Protocol),这里为0表示自动选择TCP协议(因为已经通过sock_stream指定了TCP)。该函数在什么情况下会返回什么类型的值: socket()函数在成功时返回一个非负...
关于 演示环境 $ uname -a Linux xxxxxxx 5.4.0-47-generic #51-Ubuntu SMP Fri Sep 4 19:50:52 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux AF_INET和AF_INET6 AF_INET=2
RETURN VALUE On success, a file descriptor for the new socket is returned. On error, -1 is returned, and errno is set appropriately.ERRORS EACCES Permission to create a socket of the specified type and/or pro- tocol is denied.EAFNOSUPPORT The implementation does not ...