[ Pobierz całość w formacie PDF ]
.However, once you ve loaded the DLL the first time, it ll stay in memory until you unloadit, which means that you don t have to pay that loading cost more than one time if youdon t want to.A CGI script will load the C application every time you call it.Reducedloading time is just the tip of the iceberg.Because the ISA DLL shares the samememory space as your HTTP server, you won t have to pay a time penalty forinterprocess calls or any of the overhead normally associated with using a C applicationin a separate address space.Code sharing All the server needs to do is load your DLL one time.Any applicationthat requests the services of that DLL has access to it.Obviously, code sharing is oneof the factors that leads to the lower memory costs and speed improvements over CGImentioned in the first two points.However, code sharing results in some not-so-obviousbenefits as well.For example, code sharing reduces administration time for your server,since the administrator only needs to replace one copy of any given DLL to affect everyapplication that uses it.The C applications typically used by CGI have a lot of redundantcode in them.Change a single routine and you ll need to change every C applicationthat uses the routine on your server, which means greatly increased administrator timeand the need for additional application tracking by the programmer.Reliability C applications used by CGI scripts load and execute on the server withouthaving much access to the server itself.Consequently, it s harder to create a Capplication that can monitor server events and recover from errors.What usuallyhappens is that the server will terminate an errant CGI script and the client will end upwith nothing.ISAs have full access to the server, which means that they can recoverfrom errors more easily.Therefore, the client seldom (if ever) ends up having to make arequest the second time.Filtering capability You can t provide an event-driven equivalent to an ISA using CGIand a C application.The reason s simple: a C application gets called, does its work, andthen unloads.There isn t any way that it can monitor server events over the long term.Multiple tasks in one DLL Each task that you want CGI to perform requires aseparate executable.As a result, you incur the overhead of calling each routine.ISAs,on the other hand, can contain multiple commands, each of which is a member of theCHttpServer class.Getting these six capabilities doesn t mean that you have to pay a big price in either thelearning curve or amount of coding.ISAs are just as easy to use as the CGI equivalent.Here s what the two lines of code would look like in an application:http://aux/controls/sample.exe?Paramhttp://aux/controls/sample.dll?ParamAs you can see, working with ISAPI doesn t have to be difficult.We called our ISA controlusing about the same code as we would a CGI routine.In fact, the only difference from acoding perspective is that our ISA control uses a DLL extension, while the CGI routine usesan EXE extension.Theoretically, you could switch your server to ISAs, make a few search-and-replace changes to your Web pages, and no one would notice the difference from aninterface perspective.Of course, everyone would notice the higher efficiency of your Website owing to the advantages of using ISAPI.The last advantage that I mentioned for using ISAs was that you can perform more than onetask with a single ISA.We ll see later how you implement this behavior.For right now, all youreally need to know is that the calling syntax still doesn t differ much from standard CGI callsyou may have used in the past.Here s an ISA routine call that specifies that you want to usethe DisplayStr function:http://aux/controls/sample.dll?DisplayStr?ParamAs you can see, we called something other than the default task using a second questionmark (?) in the calling string.The first parameter now tells which function you want to callwithin SAMPLE.DLL, and the second parameter contains a list of parameters.This methodof calling functions is known as a parse map, which you ll learn how to create in the latersection on creating an ISAPI extension.ISAs do share some qualities that you ll find in CGI.For one thing, your application executeson the server, not the client.This makes updating your application easy all you need to dois replace one DLL file on the server.(You do need to stop the service to update the DLL,but this is a small price to pay for the convenience of a one-machine update.) Obviously, thisis a lot easier than trying to replace an application on every client machine that accessesyour Web site.It s also one of the reasons that companies are taking a serious look atintranets to host things like a help desk and custom database applications updating oneserver is a lot easier than updating a lot of clients.TipIIS Versions 4 and above add some new capabilities that make working withISAs easier.For one thing, you can tell the server to unload the ISA aftereach call.This means that you can try the ISA to see if it works and replace itwith a new copy if necessary, all without stopping the service.Thedisadvantage of this new capability is that you ll see a slight performance hitbecause the server will need to reload the ISA every time it gets called by aclient.ISAPI versus ASP or ASP.NETYou might wonder why we haven t discussed ASP or ASP.NET in relation to ISAPI yet.Many developers compare ISAPI Extensions to Active Server Pages (ASP) as if one coulddirectly replace the other.In fact, many developers do use one technology to the exclusionof the other with great success.However, the two technologies don t necessarily compete.ISAPI has the advantage of compiled code.It performs better and uses resources moreefficiently than ASP in most cases.However, ISAPI is hard to modify because you need acompiler and special knowledge to do so.ASP requires an interpreter, so it can t competefrom a performance perspective
[ Pobierz całość w formacie PDF ]