2

Can anyone recommend an easy to use, fast and reliable C++ API for sending and receiving data over a UDP socket? Maybe something that is specifcally intended for multiplayer games?

josef.van.niekerk
  • 11,941
  • 20
  • 97
  • 157

4 Answers4

7

It's not specifically for gaming, but if you want to get down to the metal and implement your own protocol over UDP, Boost.Asio is really nice.

rjnilsson
  • 2,343
  • 15
  • 20
  • I second this. When I chose enet, boost.asio was not yet released, but it's a great choice. – KeatsPeeks Oct 26 '09 at 19:22
  • But does boost.asio give you anything but cross platform async I/O ? Surely this question is asking for more than that? – Len Holgate Oct 26 '09 at 21:31
  • 1
    @Len: I'm well aware of what asio provides, but the way the question was asked (specifically the "... Maybe ..." part) I figured Boost.Asio could be an interesting choice in case existing frameworks did not fulfill all needs – rjnilsson Oct 27 '09 at 07:21
  • I think I just read the question as asking for more than just a way to send udp using C++, but that might just have been my reading of the question. – Len Holgate Oct 27 '09 at 07:37
  • 1
    Actually, boost is a horrible choice if you want to 'get down to the metal'. *Great* choice if your looking for a high level, easy to use asio pattern - but very limited from a bare metal perspective. – JSON Jul 13 '13 at 14:11
5

enet suits your needs

  • simple
  • fast
  • reliable UDP
  • intended for real time multiplayer games

It's not object-oriented though.

KeatsPeeks
  • 19,126
  • 5
  • 52
  • 83
  • 1
    I suppose I could wrap it in a class if needed. – josef.van.niekerk Oct 26 '09 at 19:16
  • 1
    Enet is great if your looking for a low-level, reliable UDP solution. Has the useful bits of the TCP protocol without the bloat. Not just reliable, but also has flow control and congestion avoidance. – JSON Jul 13 '13 at 14:20
5

Raknet is amazingly good. So good that is the basis for networking in commercial engines like unity3d. http://www.jenkinssoftware.com

Clay Fowler
  • 2,059
  • 13
  • 15
3

You might want to look at the answers to this question: What do you use when you need reliable UDP?. I developed a C++ version of ENet (which has a C API) for a client and they use it as the basis of their gaming middleware product.

Community
  • 1
  • 1
Len Holgate
  • 21,282
  • 4
  • 45
  • 92