I recently had the "opportunity" to integrate a 3rd party library into a xAMP-based application. The library consists of a standalone windows DLL, and a couple of minimal header files. The header files comprise the ENTIRETY of the API documentation. The headers provide function prototypes, but no detail about return values, expected results, or detail of any sort, really.
The great thing is this: the producer of this library charges a good amount of money for the libraries. They even utilize FlexLM, a powerful, well-known network license manager. One really super thing I discovered, the API lists functions to allocate and interrogate the license server. However, if the license is unavailable, or something goes wrong with the license interaction; the function just hangs...forever.
To truly appreciate this, one must first think through the design for implementing the integration of this Windows DLL into my xAMP application. The DLL will almost certainly not be deployed on the same server as my webserver (which may actually be a linux machine). The challenge is to connect to the DLL from an arbitrarily hosted PHP page.
My approach was to create a windows service, which sets up a TCP socket server, listening on a specific port. This service then links the DLL and appropriate resources, and receives requests from the PHP page. The service interrogates the 3rd party library, and returns results to the calling PHP page via the same socket that the PHP page established.
The windows service is coded in C++. To get around the questionable implementation of the license calls, I simply invoke a new thread, and set a WaitForSingleObject with a predefined timeout. If I timeout, I know there was some unknown license issue. Not elegant, but this is the real world, folks.
Friday, December 21, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment