Lumina - A Sane OO Networking Architecture in C

Now that I've found a little more free time for personal projects, I'm going to try to blog about project progress and discussions... well... monologues until other's put their valuable 2-cents in.

In the past I've worked on putting together a network protocol for a project in Java. One of the issues I ran into was the apparent lack of a library like libevent or libev to make lightweight handling of multiple clients possible.

Apache Mina takes a different approach to network programming such that you effectively construct data handlers and let the framework handle data flow.

I thought that Lua and C could take advantage of such an approach in that concepts such as Separation of Concerns and basic abstraction. I began architecting Lumina to fill the void.

Some design choices/requirements have made this a little more challenging, but have important reasons.

Must compile as C

This requirement limits some code reuse particularly in that many basic data structures are necessary, such as dynamically growing arrays and maps. Also object-orientation must be hand-made. glib offers some of these abstractions for C, but it seems an overly large dependency in this framework.

So far this does not preclude the potential use of some other language that can preprocess into C, so long as it creates intelligible output and does not require writing extensive glue.

Must provide cross-platform interface

Basically this means that dependencies need to be well thought-out and where necessary be replaceable behind the scenes. The next requirement for the ability to have multiple potential implementations makes this easier.

Must have flexible implementation options

This effectively means that the dependencies for the core should be at an absolute minimum. If the core interfaces are used, swapping out the backend (libevent/libev/IOCP) shouldn't affect the library user's experience.

Must provide a Lua-accessible module

This decision will require some minor dicipline in interface design, however it will make the framework that much more usable.

Any suggestions as to resolving any of the issues pointed out would be greatly appreciated.

By on