Páginas

2011/11/10

PlayStation SUITE GDC Online 2011 (Slides) : C# Development on PSVita and more

Slides





C# : FastCGI async server using async CTP

Since the launch of the Ascyn Programming Content Preview for .NET, I wanted to use it. And now that the GIT version of Mono supports async, I have given it a try.

Since a long time I was looking for change to .NET for web development, but I wanted to have more control on what's going on than using ASP.NET or ASP.NET MVC. Now I have a FastCGI server as a library supporting FastCGI as well as a templating system compatible with django/twig that I'm going to port to Roslyn CTP.

Using async FastCGI + nginx works really fine, much better and somehow simpler than a FastCGI implementation I have done using Threads.

The point of using async FastCGI is to handle all the requests in a async way.


class Program
{
    class MyFastcgiServerAsync : FastcgiServerAsync
    {
        public override async Task HandleRequestAsync(FastcgiRequestAsync Request)
        {
            var StreamWriter = new StreamWriter(Request.Stdout);
            await StreamWriter.WriteAsync("Content-type: text/html\r\n");
            await StreamWriter.WriteAsync("\r\n");
            await StreamWriter.WriteAsync("Hello World!");
            await StreamWriter.FlushAsync();
        }
    }

    static void Main(string[] args)
    {
        new MyFastcgiServerAsync().Listen(8000);
    }
}


Source code: Async FastCGI Request Handler, Async FastCGI Library