Question from a reader


I've just had an question from a reader via email:

"I'm developing my huge server (I dont have much experience with programming servers) and as far as I know your source is the best available out there.. I would like fit it to my needs and use more c++ standard template libary instead of those buffer/linked list classes you made by yourself, but I'm afraid it would end in loss of preformance speed.. Would it be okay/worse to use instead of your buffer class and instead of those nodes? I also use boost libaries and would definetly include them in the project.. Do you think it would be a bad idea?"

And... I thought it would be beneficial to reply here rather than via email so that I don't get asked again ;)

My first thoughts are "why do you want to do this?" The Server Framework works, is efficient and the buffer interface isn't especially complex to use, and it's not especially complex to turn a complete message in a buffer into a std::string representation if appropriate or to send a std::string through the socket server interfaces. What's more, the network interface that a server is providing an interface to is a stream of bytes. It has nothing to do with strings. The data carried over it may be strings, unicode strings, or, more likely, arbitrary sequences of bytes. How does having a std::string interface to The Server Framework help? If your particular server deals in messages which are null terminated strings then the framework can easily be extended to deal with this and provide the complete strings to the derived class when they're complete...

As for using a std::list or std::vector to replace the custom node list, well, yeah, sure if that meets your performance requirements. If by using a std::list you can remove an arbitrary node from any point in the list without needing to perform a linear seach... If by using a std::vector you can efficiently manage the list of buffers or std::string that are in use...

Regarding the Boost libraries, Why would you "definitely include them". What's the requirement? There's nothing in the framework that should stop you using Boost, but surely you'd only use these libraries if you needed to, and surely, since the framework works, you'd just use them in your code that extends the framework?

So, in answer to all your questions I pose the following question: Why?

Leave a comment