Hey all, just sharing a library I've been working on over the years that finally sees the light of day. Networking for games is in sort of a sad state lately, without many great options. Enet is good, but no security scheme. Raknet was laid to rest. Some games use some Valve networking code, but that's geared towards getting people into Steam. Then there's netcode.io, but it provides no reliability layer despite having a decent security scheme. Then there's libyojimbo, but it's crazy complicated C++ garble.
And so I made cute_net.h in C for my own games. Source here:
https://github.com/RandyGaul/cute_headers/blob/master/cute_net.h. It's a single-file-header library, so using it doesn't even require modifying build scripts. The header portion is very tiny (like 200 lines of code), so it won't bloat your compile times.
It provides an optional reliability layer over UDP and has a solid security scheme baked in, making it a good option for most kinds of games. There's a small number of functions to deal with, and has a very similar api to Enet.
Client example:
https://gist.github.com/RandyGaul/e45def05353e244055dde11e7a04ac71Server example:
https://gist.github.com/RandyGaul/f3b3c0864d760c37de74be2a573c52e5In all the library doesn't do much: it merely lets clients open a secure connection to a dedicated game server. You still need a different way to authenticate clients, like a webservice of some kind. Personally I setup a web server that knows how to respond to HTTPS requests, and the only request it responds to is ones from clients trying to authenticate themselves. The entire authentication process is a single HTTPS request and response pair. From here a connect token is given to the client, used to connect to a dedicated game server and play.