如何在 IIS 7.5 上运行的 Python 中获取 REMOTE_PORT(客户端端口)?找不到 REMOTE_PORT 服务器变量!
嘿。我正在用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谷歌搜索表明使用 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.