Can somebody recommend a free C++ open source library which I will use to build a networked game using UDP. Must be available for Windows/Linux/Mac. As lightweight as possible please.
Asked
Active
Viewed 1.0k times
2
-
http://stackoverflow.com/questions/118945/best-c-c-network-library – clyfe Jan 02 '12 at 20:25
-
You can use Qt if you don't need static linking. – kechap Jan 02 '12 at 20:26
-
The lightest-weight solution is simply to call the BSD-style C socket functions directly; they are already available on all of the OS's you mentioned, and they work the 99.9% the same on each (the main difference is you need to call WSAStartup() before using them, in the Windows version only). UDP sockets are simple enough to use that a C++ wrapper library isn't really going to save you very much work anyway. – Jeremy Friesner Jan 02 '12 at 21:54
-
@Jeremy I want to avoid any Windows specifics. I've seen some of this code using sockets which has a fair bit of #ifdefs in it. – ScrollerBlaster Jan 02 '12 at 22:52
-
I don't think you'll be avoiding Windows specifics so much as moving them from your code into the network-library's code. FWIW, I count less than a dozen such #ifdefs in my networking library (which I don't think you would consider "lightweight", but FWIW it's here: http://www.lcscanada.com/muscle ) – Jeremy Friesner Jan 03 '12 at 01:12
3 Answers
4
How about SDL_Net? Not C++ really, but is lightweight and cross-platform.

Some programmer dude
- 400,186
- 35
- 402
- 621
2
A very advanced C UDP-based library, with multiplexing, reliable/unreliable/unsequenced/fragmented delivery. Cross platform. Used and created for an established open source game (Cube 2: Sauerbraten), and if you nibble at its mailing list, you'll see that it's sometimes used for commercial games too.

Lorenzo Pistone
- 5,028
- 3
- 34
- 65
1
I'm not using networking myself in C++ but I would give Boost asio a try if I had to do networking.

ascobol
- 7,554
- 7
- 49
- 70
-
1If the OP is new to Boost: The whole distribution is quite big (about 100 MB with just the sources), but Asio by itself occupies about 2.22 MB in the 1.4.80 version. You might have to add a few dependencies, but it should keep small enough. – dario_ramos Jan 02 '12 at 20:26
-
I haven't used Boost (but hear it mentioned a lot) and 2.2 MB is prohibitive. – ScrollerBlaster Jan 02 '12 at 22:43
-