linux中socket()函数实现的位置

Jak*_*ake 5 sockets linux

在 Linux 中,要创建套接字,我们包含 sys/socket.h 头文件并使用 socket() 函数。头文件位于/usr/include/sys/socket.h。

extern int socket (int __domain, int __type, int __protocol) __THROW;
Run Code Online (Sandbox Code Playgroud)

谁能告诉我socket()函数实际实现的位置。

谢谢。

yar*_*nli 5

实际上, int socket (int __domain, int __type, int __protocol) __THROW

在 glibc 中实现,

glibc 调用内核文件net/socket.c中实现的内核函数 sys_socket 。

asmlinkage long sys_socket(int family, int type, int protocol);
Run Code Online (Sandbox Code Playgroud)