Steven Fuqua

Senior Software Engineer, Microsoft

Home

Project: Citrine

Project page: Bitbucket

Citrine is a networking library I started a view years ago to help ramp up on C#, and also because I couldn't find a similar solution at the time. It solves two primary goals: provide a flexible, event-driven, Socket-based networking framework, and learn about networking in .NET, especially the 'new' paradigm introduced in .NET 3.5.

First and foremost, I wanted a client-server library that provided events for important scenarios, like gaining or losing a client, and when reading/writing a byte array was complete. On top of this, I introduced the idea of 'Protocols'. A protocol gives meaning to a byte array by abstracting it away. In the base library, I provide a string-based LineReceiver Protocol as well as a protobuf serialization Protocol.

In addition to Protocols, the actual TCP networking is abstracted through the idea of Transports, which are simply a means of conveying bytes between two endpoints. Protocols exist on top of Transports, and the TCP server and client in Citrine are implementations of the Transport abstraction.

The project taught me a lot about how networking ia handled in .NET, in addition to providing valuable experience in designing a library from the ground up. It was also the first personal project of mine with its own test suite, and writing the tests was a great learning experience.

Technology Leveraged

  • C#
  • .NET 3.5 sockets

Challenges Faced

  • Multithreaded programming
  • New API with few examples or documentation
  • Clean library design
  • Designing automated tests for a network API