套接字函数定义? [英] Socket function definition?

查看:114
本文介绍了套接字函数定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在阅读C源代码时,我看到用于打开连接的socket函数.当我使用grep在Linux内核源代码(版本3及更高版本)中搜索socket的定义时,我可以找到对socket的更多调用,但找不到该定义.

When reading C source code, I see the socket function used to open a connection. When I search for the definition of socket in the Linux kernel source code (version 3 and above) using grep, I can find more calls to socket but not the definition.

socket在哪里定义?是在以太网卡的源代码中定义的吗?

Where is socket defined? Is it defined in the source code of the ethernet card?

推荐答案

socket()函数不是内核函数,它是libc一个.

The socket() function is not a kernel function, it is a libc one.

如果您想研究socket()内部结构,请获取glibc的代码(或标准C库的任何实现),而不是内核代码.

If you want to study socket() internals get the code of the glibc (or any implementation of the standard C library), not the kernel code.

如果您打算进一步研究内核并研究内核如何实现套接字机制,请寻找系统调用sys_socketcall().

If you plan to go even deeper than that and study how the kernel implements the sockets mechanism look for the system call sys_socketcall().

这篇关于套接字函数定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆