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.
精彩评论