是否有用于“阻止"的 Windows 套接字 API 调用/选项?一系列端口 à la SO_EXCLUSIVEADDRUSE [英] Is there a Windows socket API call / option to "block" a range of ports à la SO_EXCLUSIVEADDRUSE

查看:23
本文介绍了是否有用于“阻止"的 Windows 套接字 API 调用/选项?一系列端口 à la SO_EXCLUSIVEADDRUSE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这篇(相当旧的)文章中,作者声明:

In this (rather old) article, the author states:

"端口阻塞

端口阻塞允许应用程序阻止其他应用程序对指定范围内的端口执行特定绑定.阻止端口范围时,应用程序必须选择一个连续的端口号范围,该范围介于 MaxUserPort 设置值(默认为 5000)+ 1 和 49151(对于未安装 Service Pack 的 Windows XP 和 Windows Server 2003)或65535(适用于 Windows Server 2003 Service Pack 1).应该不存在与阻塞端口范围内的端口的绑定.Windows Sockets 返回阻塞范围内的最后一个端口号作为句柄.解除阻塞(移除阻塞)时,Windows Sockets 会解除阻塞与解除阻塞请求具有相同左边缘的范围."

Port blocking allows an application to prevent other applications from performing specific binds to the ports within a specified range. When blocking a port range, the application must choose a contiguous range of port numbers that are between the value of the MaxUserPort setting (5000 by default) + 1 and either 49151 (for Windows XP and Windows Server 2003 with no service packs installed) or 65535 (for Windows Server 2003 Service Pack 1). There should be no existing bindings to the ports within the range of blocked ports. Windows Sockets returns the last port number in the blocked range as the handle. When unblocking (removing the block), Windows Sockets unblocks the range that has the same left edge as the unblock request."

我从阅读这篇文章中得到的暗示是,应用程序可以使用一些 api 来设置/取消设置它,但我已经绘制了完整的空白,试图搜索任何此类内容的文档,我也不记得曾经在我的套接字编程天.

The implication I get from reading this is that there is some api an application can use to set/unset this, but I have drawn complete blanks trying to search documentation for any such thing, nor do I recall ever seeing such functionality in my socket programming days.

Windows 中是否有这样的功能,如果有,将不胜感激指向它的文档!

Is there such a capability in Windows, and if so, pointers to documentation of it will be heartily appreciated!

推荐答案

winsock API 本身没有这样的调用,但我相信 LSP 功能.另一种(简单但肮脏的<3)方法是将 bind() 绑定到您想要阻止的所有端口.

There is no such call in the winsock API itself, but I believe there is in the LSP feature. Another (easy but dirty <3) way is to just bind() to all the ports you want blocked.

这篇关于是否有用于“阻止"的 Windows 套接字 API 调用/选项?一系列端口 à la SO_EXCLUSIVEADDRUSE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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