Re: Keep Socket connection open in ATL Server (ISAPI)

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Thank you very much for the timely response.

I am developing the ISAPI using Windows XP/IIS5.

I do not have controls over production servers so the ISAPI must support both IIS5 and IIS6.

You mentioned ISAPI itself does not have control over its lifetime.

But looks like it is a troublesome task to configure IIS to make sure the DLL will not be unloaded.

Are there any other ways to hold the socket handles?

For instance, creating a Windows Service (executable file) to hold the sockets then using memory sharing to share the socket handle between ISAPI and the Windows Service?


Another idea is creating a idle thread ( endless loop calling Sleep API)
when the DLL is loaded. Does the idle thread prevent the DLL from being unloaded?

Or any other ideas?


Thanks

Charles Zhang



Steven Cheng[MSFT] wrote:
Hello Charles,

From your description, I understand you've used ATL Server project to develop a ISAPI extension based server application. You want to make the connection from ISAPI to server application keeped from session to session(based on client request), however, you found the ISAPI extension module will be unloaded periodically, correct?

Regarding on this problem, I'd like to confirm whether you've developing the ATL server project(and test the compiled components) on XP/IIS5 or WIN2K3 server/IIS6. Based on my experience, the ISAPI code itself doesn't have particular settings to control its lifetime or cycle. It is the IIS server process which control the load/unload lifecycle of those installed ISAPI components. Normally, if the IIS site/virtual dir has choosen to cache ISAPI extension, the extension dll will be loaded at the first request of the corresponding service document/url, and it will be unloaded until the hosting IIS worker process be unloaded(shutdown or recycle). Here are two blog articles from David Wang's weblog which has included discussion on this:

http://w3-4u.blogspot.com/2006/12/qa-on-process-threading-and-dll.html

http://blogs.msdn.com/david.wang/archive/2005/10/14/HOWTO_IIS_6_Request_Proc
essing_Basics_Part_1.aspx

For your case here, you can also monitor the hosting IIS worker process of your extension dll(for IIS6, it is w3wp while for IIS5, it may vary depend on the "Protection Level" of the application virtual dir) to see whether it is because the worker process shutdown/recycle that make your ISAPI extension dll unloaded. For IIS5, you can set your webserver application virtual dir's "protection level" to "high" so that it is hosted in a single separate worker process(dllhost.exe). For IIS6, you can configure your application virtual dir to use a separate Application Pool so that it will be hosted in a individual worker process(w3wp.exe)

#Configure Application Isolation Settings for IIS 5.0 Isolation Mode
http://technet2.microsoft.com/WindowsServer/en/library/0f18f73b-03cf-4f81-92
e2-d6ee4f248c401033.mspx?mfr=true

And for IIS6, there is a setting of Application Pool to control how long idle time it will wait before the worker process(of that application pool) be shutdown, you can find it in Application Pool's setting.

http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/8
3b35271-c93c-49f4-b923-7fdca6fae1cf.mspx?mfr=true

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.

.



Relevant Pages

  • RE: Keep Socket connection open in ATL Server (ISAPI)
    ... develop a ISAPI extension based server application. ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.vc.atl)
  • Re: ASP.NET Requests Queued and IIS Restarting
    ... there is an ISAPI filter on the server. ... We will be working with the client to open a support incident with Microsoft ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Advantage of Intraweb vs. ASP.NET?
    ... It seems that most host do not understand ISAPI and thus does not support it. ... I had to rent a dedicated Windows 2003 server in order to run my ISAPI because those web host which does support it was rather costly as I had a few projects I needed to deploy at one time. ...
    (borland.public.delphi.non-technical)
  • Re: Upgrade/Sharepoint problems FP 2003
    ... To find the best Newsgroup for FrontPage support see: ... | I just upgraded from FP 2002 to 2003 and when I try to log on to my site for authoring to the server I get a message that Share ... Is this something I can control ... at my end (unix host not always FP friendly)? ...
    (microsoft.public.frontpage.client)
  • Re: Wince WebServer
    ... Microsoft Corporation ... Chris Tacke - Embedded MVP ... I'll try to write an ISAPI but I think my ... ASP server into the build. ...
    (microsoft.public.windowsce.app.development)