c++ port of lidgren?

Started by
4 comments, last by swiftcoder 9 years, 3 months ago
Quickie: Has anyone been working on a c/c++ port of lidgren OR is there any established method of communicating with a lidgren based server using c? I know lidgren uses a custom protocal.

I started writing some network services using lidgren because a) I love it and b) its quite portable but I had completely failed to look into scenarios like wanting to connect to those services from a game I wrote in c :/

Now I'm weighing up the complexity of writing a c client library or rewriting my services using basic sockets! :/
Advertisement

Have you considered simply putting a wrapper around it?

Failing that there are alternatives (i can't vouch for these as i haven't tried them myself) such as Photon.

Good luck!

If a wrapper is suitable then it would be ideal as id only have one library to keep up to date! But I was concerned about the portability of wrapping managed code - for example if me or someone else is writing a native android app in c++ would they be able to use my api? I've done unmanaged to managed wrappers before but it seems weird the other way around! Lol

Your wrapper wouldn't be portable unless you can be assured of running lidgren on the platform you are porting to. You should probably plan this in advance, keeping the wrapper as simple as possible and expecting to have to deal with things like mono as well as the official Microsoft .NET framework.

I think this is possible, it just needs careful planning before you start writing any code. I haven't googled it, but i am betting someone has beaten you to the punch and already implemented such a wrapper with lidgren being such a popular library...

Mono and .NET are both open source at this point, and available on all platforms that matter. Thus, it should be possible to create a wrapper that goes C++ -> C# (which is, admittedly, the "wrong" direction compared to most other uses :-) You would have to include the Mono runtime with your wrapper/C-level code.

An alternative is to use a C level library, such as RakNet, instead of Lidgren, and write a C# -> C wrapper to import RakNet into your C# code. This would probably be more straightforward, and more palatable to developers used to doing "only C" and not including large support libraries.
enum Bool { True, False, FileNotFound };

An alternative is to use a C level library, such as RakNet, instead of Lidgren, and write a C# -> C wrapper to import RakNet into your C# code.

Happily, RakNet comes with a compile-it-yourself C# wrapper these days.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement