I want to create a apache extension for my special protocol which listens on the same port as apache but on a specific directory or file like PHP. I need this to power my game with a custom server but not with PHP. I can’t listen on a different port or different server.
I don’t want to create a PHP file or something similar. I need a complete executable program where I can dynamically allocate memory etc. the program is completely outside of the apache server, but the apache ‘passes-through’ special requests to this program (for example the .foo files or the /foo/ directory.
I need a tutorial or a help to create a custom extension for apache.
UPDATE:
I want to create a daemon running in the background of my server, and then when apache sends a request, it forwarded this to my daemon, and then the daemon generates the request, and then send an answer. this is important that is not like a php script file or a perl because this is not executed once, the program is running all time, and waiting for the apache to send something. I don’t know how to communicate with apache. But I think this is not a CGI, because if I read well, the CGI running is like: apache gets the request, and then START a new process for my php or perl file, sends the data through arguments and stdIN, and then when the process ends, reads the answer form the stdOut and send it back, the process then finished.
But my program still running. I need to run my program in the background all time because I need to store data in the memory which is loaded at startup.
like this.:
http://i53.tinypic.com/v45jzo.jpg
You don’t need a special extension, just register a CGI handler that calls your processing code.
Edit
You can setup apache to proxy requests to your daemon.
You will need to return a properly formatted HTTP response or it wont work. You should read up on Apache and web based communications in general to get a better idea what is needed in your daemon.
P.S. Writing an Apache extension is much more difficult an not portable.