FastCGI ASP.NET Server Status Report 1
Posted by Brian on June 1, 2007
This is a status report for the week of May 28 – June 1. A lot of great things have been accomplished this week and one major roadblock has been hit.
THIS WEEK’S ACCOMPLISHMENTS
The greatest accomplishment has been the creation of a basic FastCGI server that can communicate with the Cherokee Web Sever via TCP sockets. A test page outputs a HTML document with the page’s FastCGI parameters (equivalent to the environment variables passed to a standard CGI document) and the POST data received.
You can test this for yourself by:
- Downloading and installing the Cherokee Web Server <http://www.cherokee-project.com/downloads>
- Configuring <file:///etc/cherokee/cherokee.conf> to include the following lines:
vserver!default!extensions!aspx!handler = fcgi vserver!default!extensions!aspx!handler!balancer = round_robin vserver!default!extensions!aspx!handler!balancer!type = interpreter vserver!default!extensions!aspx!handler!balancer!local1!host = localhost:1234 vserver!default!extensions!aspx!priority = 99999
- Check out my project via svn: <http://mono-soc-2007.googlecode.com/svn/trunk/brian/FastCgi>
- Use monodevelop <http://www.monodevelop.com/Main_Page> to the project.
- Run “mono FastCgi/bin/Debug/server.exe”
- Run “cherokee” as root.
- View <http://localhost/any-page.aspx> Feel free to make a page post to it to see the raw results.
- Press “Enter” to kill the FastCGI server and Ctrl-C to kill the web server.
PLANS FOR THE COMING WEEK
This week I plan to finish the last bits of the FastCGI specification by handling FCGI_GET_VALUES, adding support for server options (max requests, max connections, multiplexing), and supporting the multiplexing of responses by threading the Responder class. Additionally, I plan on bonding my classes to Mono.WebServer classes. At current inspection, it appears I can modify FastCgi.Server to inherit Mono.WebServer.WebSource and FastCgi.Connection to Mono.WebServer.Worker. And of course, there’s cleaning and commenting my code.
ONE MAJOR OBSTACLE
You may have noticed that I opted for Cherokee rather than Apache in my example. In default configuration, which is the only one I can figure out for Apache’s mod_fcgid, the server creates a socket at STDIN_FILENO which the FastCGI server is supposed to call accept() on. Unfortunately, I cannot find a mechanism within the Mono framework for accessing an unmanaged socket. The main problem is that the socket is already bound and the Apache server is waiting for it to accept() when the application begins, so the only action available would be to deal strictly with unmanaged sockets.
The .NET 2.0 framework, does however provide a structure called SocketInformation for transferring a socket from one process to another. It is not yet implemented in Mono (I think because Linux might not have a DuplicateAndClose option for sockets), but it may provide a workable solution.
As it stands, this problem is standing in the way of support for the Apache server and will need to be resolved in some way.
RESOURCES USED THIS WEEK
- MSDN – Looking up information on various classes and methods.
- FastCGI Specification – Obvious reasons.
- In Dealing with the socket problem:
- Manpages – Looking up information on socket access.
- FastCGI C++ and Java Implementations – To study other methods of dealing with the socket.
- <sys/socket.h> – Getting information on the socketaddr structure.
- http://blogs.msdn.com/malarch/archive/2005/12/26/507461.aspx – Transferring sockets between managed and unmanaged processes.
Sincerely,
Brian Nickel











TagLib# Development Blog » TagLib# 2.0 RC2 AKA “Almost…” said
[...] Today marks the second release candidate for TagLib# 2.0 (1.9.99995). Some ground was lost with documentation, but it now conforms much more to Microsoft’s guidelines for libraries. I apologize for not being quicker about this and bug fixes, but I’ve been a little swamped this week with Google’s Summer of Code. [...]