M
Mark
Hi...
We've implemented a server process using HttpListener to get and process
certain requests, but we've been noticing some odd serialization that
reminded me of a quirk in the client code.
We recently discovered an odd behavior of HttpWebRequest in the client code
where mixing sync and async methods resulted in everything quietly being
sync. Specifically, we were using GetRequestStream() to send the data up
synchronously then calling BeginGetResponse() to wait for the answer async.
Well, it turned out that if you call a sync method first the async calls
magically turn into synchronized ones - a rather undocumented behavior.
Now we're seeing some similar quirks on the server side with HttpListener.
We use BeginGetContext() to listen for a request. Our callback calls
EndGetContext() to get the details and then immediately calls
BeginGetContext() again to wait for another request.
But then we read the request synchronously, post the work in a queue with
the associated response object and move on.
What we're seeing is that if the client sends several requests in a row, it
blasts right through them but the server doesn't acknowledge even reading the
2nd request until after the response to the first request is written to and
closed.
Does HttpListener have some implicit serialization behavior like
HttpWebRequest?
Thanks
Mark
We've implemented a server process using HttpListener to get and process
certain requests, but we've been noticing some odd serialization that
reminded me of a quirk in the client code.
We recently discovered an odd behavior of HttpWebRequest in the client code
where mixing sync and async methods resulted in everything quietly being
sync. Specifically, we were using GetRequestStream() to send the data up
synchronously then calling BeginGetResponse() to wait for the answer async.
Well, it turned out that if you call a sync method first the async calls
magically turn into synchronized ones - a rather undocumented behavior.
Now we're seeing some similar quirks on the server side with HttpListener.
We use BeginGetContext() to listen for a request. Our callback calls
EndGetContext() to get the details and then immediately calls
BeginGetContext() again to wait for another request.
But then we read the request synchronously, post the work in a queue with
the associated response object and move on.
What we're seeing is that if the client sends several requests in a row, it
blasts right through them but the server doesn't acknowledge even reading the
2nd request until after the response to the first request is written to and
closed.
Does HttpListener have some implicit serialization behavior like
HttpWebRequest?
Thanks
Mark