Hello everyone,

I can not find an asynchronous HTTP server from Google. So, I write my own code. My two questions,

1. I am wondering whether my code is correct? (I have tested basic function, but I would like guru like you to give comments) do you have any better implementations for reference to achieve better throughput of server?

2. I call EndGetContext before retrieving request/response stream from HTTP context, in order to wake up server (so that another incoming HTTP request could be handled while current request is handled in process). My concern is whether call EndGetContext early before complete read/write request/response stream is safe -- is it safe to read/write request/response stream after calling EndGetContext - the data in the streams are still valid and not released?

My code,

        public void StartListener()

            IAsyncResult result;
            server = new HttpListener();
            // server.Prefixes.Add
            while (true)
                result = server.BeginGetContext(new AsyncCallback(this.MyHttpCallback), server);


        // callback function when there is HTTP request received
        private void HttpCallback(IAsyncResult result)
                // notify server call is complete, so that server could have better throughput
                HttpListenerContext context = server.EndGetContext(result);

                // Handle Request here, e.g. get request stream and response stream from context;

thanks in advance,