سؤال

*) I have a Delphi XE ISAPI dll running under IIS 7.5 - Server 2008 R2. The DLL launches an instance of TISAPIApplication. The application resides at a discreet, fixed, predetermined URL, and listens on a particular port (not port 80) for requests - all of this is of course a 'standard configuration'.

*) On my server, I have several dlls, each launching a different instance of the TISAPIApplication, mapped to a different URL, and listening on a different port. At runtime, I distinguish between various instances of the application (Dev, Prod, FailOver etc) based on the port number (easier than parsing URL's).

*) I have looked around in the docs and source code of TISAPIApplication and its ancestor and associated classes, but I can't find anywhere a property that tells me on what port a particular instance of the application is listening - the port seems to be available only on a request by request basis. It seems to me that since in simple deployments the listening port is usually static, I should be able grab that port value on app startup - this will facilitate allocating certain resources then, instead of waiting for a request to come in, etc.

*) Anyone know how to do this? What property do I need grab, and from where? In fact, I can't find anything at all that will tell me anything about the URL the application itself resides at - everything seems to work on a per request basis.

( Please - I'm not looking for workarounds telling me how to do it via the request, or that HTTP is stateless and everything works on a per request basis - I know those workarounds and don't want to use them. And, although threads are spawned by ISAPI to handle requests in a 'stateless' manner, a TISAPIApplication instance is launched when the ISAPI dll is loaded by IIS and this TISAPIApplication instance persists througout the lifetime of the ISAPI application and contains state information that is valid for the lifetime of the application instance ).

TIA

هل كانت مفيدة؟

المحلول 2

I think maybe I'm trying to do something here that isn't entirely valid: Even though simple apps generally have a listener sitting on a designated port that doesn't change, it doesn't have to be that way - the only way to determine the listening port with certainty is from the request itself, not before -so TISAPIApplication should not be persisting information about the listening port, which is essentially volatile.

نصائح أخرى

The ISAPI function GetServerVariable (http://www.podgoretsky.com/ftp/Docs/Internet/Late%20Night%20ActiveX/ch7.htm#CHttpServerContextObject - Table 7.7 HTTP Environment Variables) can return the SERVER_PORT variable. Maybe this function can be called when the DLL is initialized.


As you wrote

The application resides at a discreet, fixed, predetermined URL, and listens on a particular port (not port 80) for requests

and

At runtime, I distinguish between various instances of the application (Dev, Prod, FailOver etc) based on the port number

I assumed that you need to do something before the first request hits the app, like resource-consuming initialization tasks, instead of doing them with every request. In this case a function which can be used in an early stage of the application life cycle would be an advantage. However I did not do a research on the ISAPI application lifecycle to find out how this is usually done.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top