async and await in Socket
async/await improvement in .NET 4.5 / C# 5 is very major changes. I using socket extensively lately to build real-time data transport. The performance is absolutely critical in this area. I try to find the improvement in raw Socket in System.Net.Sockets. But there’s no awaitable method for Accept, Receive and Send. Unfortunately the async method is not what you think it is. It’s EAP not awaitable method.
I and my friend discussing about this yesterday and use the very simple solution to solve this problem. We combine the TPL and APM from .NET. The idea in this stackoverflow post will show you the implementation.
But wait, don’t just jump to implement that just yet. Please read this valuable blog post from the Parallel Team in .NET
There are a lot of things need to be considered right ? Also another article about this need to be read also and that’s the basic of the rationale for the previous blog post.
So are you ready to make your socket awaitable ?
Less blocking thread, more performance