C++: An iostreams-based socket library

I am currently working on an iostream sockets library for C++. See bigthicket.us for an overview in Dinkumware-style header documentation (which is now very out of date, but it still gives you the rough idea).

I’ve probably spent roughly one man-week on it (rough estimate). I now partly understand why there isn’t an existing implementation like this. It’s not easy. Why bother with inheriting from standard library classes when you can just write direct wrapper classes and go about writing socket-based network software just like before?

Getting the sockstream class to write to a socket and have a server receive it was pretty easy. Almost trivial, I’d say.

Accepting connections and receiving data on them is another ballpark alltogether. Buffering for incoming data is much more complex than it is for outgoing data, which is tricky to deal with, because I don’t want to rewrite all of std::streambuf. I want to inherit as much as possible from std::streambuf and only provide minimal overloading of virtual functions to get the functionality that I want. The standard documents have been very helpful so far, and so I will continue to rely on them to aid my understanding of all the plumbing involved.

Anyway, all that is to say, I can understand now why the existing C++ sockets wrappers were written the way they were.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">