c++ - DisableAddressSharing注册表不起作用

标签 c++ windows sockets tcp msdn

我正在尝试使用DisableAddressSharing注册表来禁用套接字之间的端口共享,但是它不起作用。
DisableAddressSharing设置为1。

socket server1 = bind(INADDR_ANY,Port)
socket server2 = bind("127.0.0.1",Port)

如果我在server1套接字中使用SO_EXCLUSIVEADDR,则地址共享被禁用。是否有任何原因注册表无法正常工作?

最佳答案

必须重新启动才能使此设置生效。

As a workaround, Microsoft provides a registry setting that will globally (system-wide) prevent all sockets from reusing any port that is already in use. This is done by setting to 1 the "DisableAddressSharing" value of the "HKLM\System\CurrentControlSet\Services\Afd\Parameters" key. (Reboot required for the setting to take effect). The administrator should first confirm that disallowing socket reuse globally does not break the functionality/correctness of existing legitimate servers on the system. If it's safe, the setting described above should be used to apply this security measure.


在实现此功能之前,请参阅Microsoft关于SO_EXCLUSIVEADDRUSE的文章。

关于c++ - DisableAddressSharing注册表不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62327492/

相关文章:

c++ - 在 C/C++ 中将两个大数相乘

c - 如何在 C 中打开 Windows 中的默认 Web 浏览器?

c++ - 以下代码是否可能存在内存泄漏?

c++ - 简单Qt程序中的 undefined reference

windows - 为什么较新的 Windows 版本仍支持某些旧的 Win16 API?

ruby - 中间人服务器在 Windows 0.0.0.0 :4567 上不工作

c - 用 C 语言发送 IPv6 数据包的示例代码

c++ - struct constructor会占用struct空间内的空间吗?

java - 将 float 据发送到我的客户端应用程序

c++ - boost program_options : help vs. 有意义的选项