So a long time ago I wrote some posts on buffer management in TCP servers (it might be worth going back and reading them as they explain why buffer management is important. There have been a few comments lately asking for more complete examples. Funny enough that’s just what I have been working on lately. So here is the first of a set of code drops of some code that will be open sourced (consider it MIT/MSPL now) in its entirety (a nice little framework for writing scalable servers, TCP transports, etc). The project doesn’t have an official name yet and is being run on our local svn so I will just upload a zip file for now.
You can download the source here: http://codebetter.com/files/folders/codebetter_downloads/entry181822.aspx
A quick run down of what is there.
BufferManager.cs – The main Buffer Manager class
BufferPool.cs – A class that abstracts a set of buffers to allow common operations
BufferPoolStream.cs – An adapter to the stream interface for a BufferPool
There are associated tests for these classes <> 75.
I know this seems like a lackluster post, but the code is worth going through. And if anyone has a good name for this library, let me know.