linux / if.h和net / if.h有什么区别?

前端之家收集整理的这篇文章主要介绍了linux / if.h和net / if.h有什么区别?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
评论说net / if.h是GNU C库的一部分,linux / if.h说它是“LINUX操作系统的TCP / IP协议套件的实现”.

但为什么有两个,每一个有什么用?

解决方法

最初,两者都提供数据结构来管理网络接口.linux / if.h特别与 Linux内核的网络接口交互更相关.实际上,它在文件的开头就是这样说的:
/*
 * INET     An implementation of the TCP/IP protocol suite for the LINUX
 *      operating system.  INET is implemented using the  BSD Socket
 *      interface as the means of communication with the user level.
 *
 *      Global definitions for the INET interface module.
 */

net / if.h是glibc的文件用于相同的目的,最初是更多的用户空间.

重要的是要注意,如果你要使用它们(它们共享一些结构但不是全部),包含顺序非常重要,建议在大多数情况下在net / if.h之前包含linux / if.h.

原文链接:https://www.f2er.com/linux/394076.html

猜你在找的Linux相关文章