开发者

How to get the REMOTE_PORT (the client port) in Python running at IIS 7.5? REMOTE_PORT server variable cannot be found!

Hey. I'm coding a cgi in Python, running on an IIS 7.5 web server, o开发者_JAVA百科n 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.


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:

  • PyISAPIe
  • isapi-wsgi
  • pywin32's isapi module (note, those pywin32 docs can be browsed only in a local copy apparently, but you can read that page to learn more)

There are probably others.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜