gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 10:30:46 25 4
gpt4 key购买 nike

我正在尝试使用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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com