Solved

Web application with Windows (2000), Delphi 5/7 and Apache

Posted on 2006-10-26
3
317 Views
Last Modified: 2011-09-20
I wish to create a web application using Delphi 5 or Delphi 7
The application will need to :-
-  know which session it is talking to
-  be able to create a thread (within itself)
-  use components
-  send text/streams back to the client
-  be told to expire when the session has expired (to allow cleanup)

I only expect a total of < 20 instances (unique sessions) to be running at any 1 time.

Which type of web app should I create?
ISAPI/NSAPI, CGI stand-alone, Win-CGI, something else?
any suggestions welcome, and let me know if you need more info
0
Comment
Question by:TheRealLoki
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
Wim ten Brink earned 500 total points
ID: 17817619
Not much experience with building Apache modules myself but here are my two cents...

About sessions, I think you might have to do session handling in your application itself. Often you get a session-ID from somewhere (Cookie, POST data or some URL parameter) and that will identify your session. If you have to create your own session ID's then use GUIDs, since they are very useful as unique identifiers...

Creating separate threads in a webserver is similar to creating threads in normal applications, although you have to be aware of the risk that your main thread might time-out before the other threads are finished. Creating child threads are therefor a bit risky since you might run out of resources. If you can avoid it, then don't use threads. The use of threads in web applications don't make much sense anyway since the webserver itself will run every request in it's own thread anyways.

For component use, use a WebModule or a data module. You won't be able to use visual components, though. Make sure that your components won't display some messageboxes or whatever since there will be no one available to click the [OK] button once it pops up. :-)

Sending data back to the client is not a real problem either. It's basic behaviour of the web module.

And about expiration... This too should be no problem since the module would just exist long enough to handle a single request before it is killed again. Keep in mind that webservers are stateless and thus every request you send to it will result in an action being started, it processes the incoming data, it generates the output and then the action is closed again! It won't continue to run until the next request...

It seems to me that you want some process to run in the background while a user is sending multiple requests to the server. To do this, you should actually split your project up in two parts. The first part is the web module which will be run from Apache. The second part should be a system service that will run in the background. Your webserver should talk to the system service, providing it the details about what it should do and the system service can run a thread for every session for the amount of time specified. The communication between system service and webserver can be done through named pipes, through TCP/IP and through many other inter-process communication tricks.

With a small amount of instances I would suggest that you start this project as a CGI application. It's easier to debug, although it might be slow if you have a huge amount of visitors. The advantage is that a CGI application is loaded every time a request is made and terminates when the request is done. An ISAPI DLL stays in memory after the first request and the only way to free it is by closing down the webserver. This means that every time you want to update the ISAPI DLL, you will have to stop the webserver, overwrite the DLL and then start the webserver...
Once your CGI application is working you can easily convert it to an ISAPI application if need be.
0
 
LVL 17

Author Comment

by:TheRealLoki
ID: 17839131
Thanks, I'll give that a go
It makes sense to use another background process, as long as I can pass it the "session id" or a guid each time, it should be fine. I can build in its'  own "lifetime"
0
 
LVL 17

Author Comment

by:TheRealLoki
ID: 17912301
I still haven't had a chance to fully implement it yet, but I've left you waiting long enough. Looks promiising so far, so here's your points
Thanks
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now