网络编程:套接字函数:地址族 Vs 协议族

发布于 2024-10-17 02:11:41 字数 612 浏览 2 评论 0原文

我刚刚开始学习网络编程。在查看套接字函数时,有些使用 PF_INET,有些使用 AF_INET。在 wikipedia 中查看,它说这样的设计用于通过以下方式启用不同地址族的使用不同的协议族。目前是否有支持多种地址类型的协议系列?

另外,当我搜索地址族与协议族时,我遇到了此错误:

Address family not supported by protocol family

这是否意味着存在支持多个地址族的协议?

我遇到了这个声明

you shouldn't necessarily expect to be able to use NS addresses with ARPA Internet protocols

什么是 NS 地址?

谢谢。

I just started with network programming. When looking at the socket function some use PF_INET and others use AF_INET. Looked in wikipedia, it says such design was used to enable the usage of different address families by different protocol families. Are there any such protocol families today which support multiple address types?

Also I came across this error when I was searching for Address family Vs Protocol family:

Address family not supported by protocol family

Does this mean there are protocols supporting multiple address families?

I came across this statement

you shouldn't necessarily expect to be able to use NS addresses with ARPA Internet protocols

What are NS addresses?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

财迷小姐 2024-10-24 02:11:41

socket 的 Windows 文档说地址族是第一个参数;我的 Linux 机器上的手册页说这应该是协议族。从与平台无关的角度来看,Linux 版本似乎稍微正确一些——理论上,套接字有协议族,地址有地址族,两者应该兼容。

但实际上,内置协议的 PF_AF_ 宏具有相同的值(在 Linux 和 Windows 中)。我想对于大多数操作系统来说都是类似的情况,因为所有常见的协议系列都有一个地址系列。 (您可能认为 IP 会有两个,但事实并非如此。IPv4 和 IPv6 有不同的协议族。)这(以及 C 相对较弱的类型)允许它们几乎可以互换使用。

请注意,不能保证所有操作系统或某些第三方驱动程序支持的协议等都是如此。在这些情况下,您应该查阅特定平台的文档。

至于“NS地址”是什么,据我所知,它们是施乐史前的一部分 网络系统协议(类似于 TCP/IP 的协议族,但不同且不兼容,现代 PC 未使用)。除非您使用的是陈旧的系统,否则您不会看到它们在使用中。我不明白为什么要保留这个例子。

The Windows documentation for socket says that the address family is the first argument; the man page on my Linux box says that that should be the protocol family. The Linux version seems slightly more correct from a platform-agnostic perspective -- in theory, the socket has a protocol family and the addresses have address families, and the two should be compatible.

In practice, though, the PF_ and AF_ macros for the built-in protocols have the same values (in both Linux and Windows). I imagine it's a similar story for most OSes, since all the common protocol families have one address family. (You'd think IP would have two, but nope. There are separate protocol families for IPv4 and IPv6.) This (along with C's relatively weak typing) allows them to be used pretty much interchangeably.

Note that there's no guarantee about this being the case for all OSes, or for protocols supported by some third-party driver, etc. In those cases, you should consult the documentation for your particular platform.

As for what "NS addresses" are, far as i can tell, they're part of Xerox's prehistoric Network Systems protocol (a protocol family sorta like TCP/IP, but distinct and incompatible and unused by modern PCs). You won't see them in use unless you're working with archaic systems; why that was kept as an example is beyond me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文