Posted on September 30, 2005 by Doolwind


I had a couple of extra hours last night to code and decided it was time to start implementing the Network System for CIC using RakNet. I’m pleased to say that RakNet is everything I had hoped it would be. It took about 15 minutes to get my client and server implemented and connected to each other. The tutorials are helpful and any problem I ran into I solved quite quickly. The only substantial issue I had was my first message I passed was not working as I expected. This was simply because I didn’t cast the enum of it’s type to a (uchar) and so it was taking 4 bytes rather than 1.

I had spent a fair amount of time designing my network system and so far I’m happy with how well the implementation is going. My two main goals for this system were:

1) Centralize the creation of new events/messages so that the networking system needs little if any changes
2) Make the reading and writing of packets use the exact same code to remove any problems with reading data differently to how it was written.

My design meets both of these requirements nicely, once I’ve implemented the core system I’ll put up some diagrams and give a more in-depth explanation of how I accomplished this. I am only using the lowest level parts of RakNet as I prefer having complete control over what’s being sent. RakNet feels very similar to the socket wrapper I wrote for my last personal project which is why it feels so natural to use.

I’ll keep you posted on how my progress with RakNet and my networking goes and will hopefully have the core system with CIC’s 3 events implemented by next week.