views:

319

answers:

1

I don't mean to ask, is Comet easier in ASPNET than in Jetty? I mean, is Comet easier inn either ASPNET or Jetty, as compared to other alternatives? I think the asynch capabilities of ASP.NET and Jetty specifically make Comet more scalable when implemented on those platforms and I'd like to confirm that.

ASPNET introduced "Asynchronous pages" back in 2005. The idea was to apply the familiar .NET asynch model to ASP.NET page processing.

public partial class AsyncPage : System.Web.UI.Page
{
    private WebRequest _request;

    void Page_Load (object sender, EventArgs e)
    {
        AddOnPreRenderCompleteAsync (
            new BeginEventHandler(BeginAsyncOperation),
            new EndEventHandler (EndAsyncOperation)
        );
    }

    IAsyncResult BeginAsyncOperation (object sender, EventArgs e, 
        AsyncCallback cb, object state)
    {
        _request = WebRequest.Create("http://msdn.microsoft.com");
        return _request.BeginGetResponse (cb, state);
    }
    void EndAsyncOperation (IAsyncResult ar)
    {
        string text;
        using (WebResponse response = _request.EndGetResponse(ar))
        {
            using (StreamReader reader = 
                new StreamReader(response.GetResponseStream()))
            {
                text = reader.ReadToEnd();
            }
        }

        Regex regex = new Regex ("href\\s*=\\s*\"([^\"]*)\"", 
            RegexOptions.IgnoreCase);
        MatchCollection matches = regex.Matches(text);

        StringBuilder builder = new StringBuilder(1024);
        foreach (Match match in matches)
        {
            builder.Append (match.Groups[1]);
            builder.Append("<br/>");
        }

        Output.Text = builder.ToString ();
    }
}

Q1: Doesn't this make ASP.NET scale much better for Comet-style applications? Has anyone used this and tested it?

I think that other server-side frameworks also have something similar. If I'm not mistaken Jetty has something like this, to enable better scale in Comet scenarios.

Q2: Can anyone shed light on that?

+4  A: 

The asynchronous processing in .NET does indeed provide a basis for building comet applications. Specifically, it's the IHttpAsyncHandler that can be used as a foundation.

That said, without a third-party library, implementing Comet from scratch is... difficult. There's a .NET implementation of Comet for IIS called WebSync that would compare against Jetty.

Anton
Too bad there is no open source product in the ASP.NET space that I can find. Plenty of choices in the Java space.
Kelly