如何在 IIS 7.5 上运行的 Python 中获取 REMOTE_PORT(客户端端口)?找不到 REMOTE_PORT 服务器变量!

发布于 2024-08-14 13:58:27 字数 263 浏览 1 评论 0原文

嘿。我正在用 Python 编写一个 cgi,在 Windows 上的 IIS 7.5 Web 服务器上运行。我想获取客户端连接到它的 tcp 端口(通常是服务器环境变量 REMOTE_PORT)。

我尝试像 os.environ.keys() 中那样一路查找密钥,我可以获得用户的 IP 地址、他的浏览器、平台,但没有可用的远程端口。

我已经安装了 .NET Framework 3.5 SP1。

有人能弄清楚发生了什么事或有办法实现吗?

谢谢。

Hey. I'm coding a cgi in Python, running on an IIS 7.5 web server, on Windows. I would like to get the tcp port (usually was the server environment variable REMOTE_PORT) from which the client is connecting to it.

I've tried to look up all the way throuhout the keys as in os.environ.keys() and I can get the user IP address, his browser, platform, but no remote port available.

I have .NET Framework 3.5 SP1 installed already.

Could anyone please figure out what's happening or a way to make it?

Thanks.

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

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

发布评论

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

评论(1

谁许谁一生繁华 2024-08-21 13:58:27

谷歌搜索表明使用 ASP.NET 和 PHP 解决方案的人也有类似的问题,并且自 IIS 5.0 以来,该变量还没有被可用。我的印象是您必须调用名为 GetServerVariable() 的例程来检索它。该例程听起来可以通过各种库获得,您可以按原样使用这些库或从以下位置提取代码:

可能还有其他。

Googling suggests people with ASP.NET and PHP solutions have similar problems and that since IIS 5.0 that variable hasn't been available. I get the impression you have to call a routine called GetServerVariable() to retrieve it. That routine sounds like it's available through various libraries, which you may be able to use as-is or lift code from:

There are probably others.

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