Programming · Summer of Code 2007

FastCGI ASP.NET Server Status Report 1

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.


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:

  1. Downloading and installing the Cherokee Web Server <>
  2. 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
  3. Check out my project via svn: <>
  4. Use monodevelop <> to the project.
  5. Run “mono FastCgi/bin/Debug/server.exe”
  6. Run “cherokee” as root.
  7. View <http://localhost/any-page.aspx> Feel free to make a page post to it to see the raw results.
  8. Press “Enter” to kill the FastCGI server and Ctrl-C to kill the web server.

Status Report 1


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.


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.


  • 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.
    • – Transferring sockets between managed and unmanaged processes.

Brian Nickel


One thought on “FastCGI ASP.NET Server Status Report 1

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s