{"id":44610414,"url":"https://github.com/nathhB/nbnet","last_synced_at":"2026-02-26T22:01:18.161Z","repository":{"id":43368140,"uuid":"282621882","full_name":"nathhB/nbnet","owner":"nathhB","description":"single header C(99) library to implement client-server network code for games","archived":false,"fork":false,"pushed_at":"2026-02-14T08:35:05.000Z","size":1880,"stargazers_count":542,"open_issues_count":4,"forks_count":33,"subscribers_count":7,"default_branch":"master","last_synced_at":"2026-02-14T14:04:30.041Z","etag":null,"topics":["c","c99","game-development","single-header","single-header-lib","udp","webrtc"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"zlib","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nathhB.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-07-26T09:58:45.000Z","updated_at":"2026-02-14T08:35:09.000Z","dependencies_parsed_at":"2023-02-18T22:45:59.570Z","dependency_job_id":"5fe068fb-8c75-4bcd-b6ac-8281d9e5c295","html_url":"https://github.com/nathhB/nbnet","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/nathhB/nbnet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathhB%2Fnbnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathhB%2Fnbnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathhB%2Fnbnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathhB%2Fnbnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathhB","download_url":"https://codeload.github.com/nathhB/nbnet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathhB%2Fnbnet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29874452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T21:05:00.265Z","status":"ssl_error","status_checked_at":"2026-02-26T20:57:13.669Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","c99","game-development","single-header","single-header-lib","udp","webrtc"],"created_at":"2026-02-14T12:00:22.735Z","updated_at":"2026-02-26T22:01:18.148Z","avatar_url":"https://github.com/nathhB.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"# nbnet\n\n![logo](logo/logo.png \"Logo\")\n\n![nbnet](https://github.com/nathhB/nbnet/actions/workflows/nbnet.yml/badge.svg)\n[![CodeFactor](https://www.codefactor.io/repository/github/nathhb/nbnet/badge/master)](https://www.codefactor.io/repository/github/nathhb/nbnet/overview/master)\n[![Docs site](https://img.shields.io/badge/docs-GitHub_Pages-blue)](https://nathhb.github.io/nbnet)\n\n[![](https://dcbadge.vercel.app/api/server/P9N7fy677D)](https://discord.gg/P9N7fy677D)\n\n\u003e [!IMPORTANT]  \n\u003e If you are interested in giving nbnet a try, please consider using version 3.0 (available in 3.0 branch). I'm still working on it, but it's usable already and will be released soon(TM). 3.0 improves a lot of stuff internally and provides a cleaner API. The documentation is lacking (all READMEs are obsolete), but you can look at the examples, which are up to date.\n\nnbnet is a single header C (C99) library designed to implement client-server architecture, more precisely for online video games. The library is based on this [great series of articles](https://gafferongames.com/) by Glenn Fiedler.\n\nnbnet can target different protocols such as UDP or [WebRTC](WEBRTC.md) through \"drivers\" (see below for more information).\n\nThe API is meant to be as straightforward as possible and relies on event polling, making it easy to integrate into a game loop.\n\n**Disclaimer**: nbnet is in the early stages of its development and is, first and foremost, a learning project of mine as I explore online game development. If you are looking for a battle-tested, production-ready library, this is probably not the one.\n\nYou can see nbnet in action [in this video](https://www.youtube.com/watch?v=BJl_XN3QJhQ\u0026ab_channel=NathanBIAGINI).\n\nIf you want to discuss the library or need help, join the [nbnet's discord server](https://discord.gg/esR8FSyPnF).\n\n## Features\n\n- Connection management\n- Sending/Receiving both reliable ordered and unreliable ordered messages\n- Sending/Receiving messages larger than the MTU through nbnet's message fragmentation system\n- Bit-level serialization (for bandwidth optimization): integers (signed and unsigned), floats, booleans, and byte arrays\n- Network conditions simulation: ping, jitter, packet loss, packet duplication, and out-of-order packets)\n- Network statistics: ping, bandwidth (upload and download) and packet loss\n- Web (WebRTC) support (both natively and through WASM using [emscripten](https://emscripten.org/docs/introducing_emscripten/about_emscripten.html))\n\n## Thanks\n\nthe native WebRTC driver relies on:\n\n- [libdatachannel](https://github.com/paullouisageneau/libdatachannel)\n- [json.h](https://github.com/sheredom/json.h)\n\n## Made with nbnet\n\n### Boomshakalaka\n\nA fun action game that runs into a web browser, by Duncan Stead (@duncanstead86).\n\n[See on YouTube](https://www.youtube.com/watch?v=SJHvXV03uwQ).\n\n### nbBR\n\nA WIP battle royal game playable in a web browser.\n\n[See on YouTube](https://youtube.com/playlist?list=PLgcJGzE_fX4criMxQAw3pm24RQYMYRLEI)\n\n### Llamageddon\n\nAn online multiplayer RTS made for the Ludum Dare 49.\n\nhttps://ldjam.com/events/ludum-dare/49/llamageddon\n\n### nb_tanks\n\nA little online tank game prototype.\n\n[See on GitHub](https://github.com/nathhB/nb_tanks)\n\n## Bindings\n\nA list of user-contributed bindings (they are not officially supported, so they may be outdated):\n\n- [nbnet-sunder](https://github.com/ashn-dot-dev/nbnet-sunder) by [@ashn](https://github.com/ashn-dot-dev) ([Sunder](https://github.com/ashn-dot-dev/sunder) is a modest systems programming language for Unix-like platforms)\n\n## Drivers\n\nnbnet does not directly implement any low-level \"transport\" code and relies on *drivers*.\n\nA driver is a set of function definitions that live outside the nbnet header and provide a transport layer implementation for nbnet used to send and receive packets.\n\nnbnet comes with three ready-to-use drivers:\n\n- UDP: works with a single UDP socket, designed for desktop games\n- WebRTC (WASM): works with a single unreliable/unordered data channel, implemented in JS using the emscripten API\n- WebRTC (Native): works the same way as the WASM WebRTC driver but can be natively compiled \n\n## How to use\n\nIn *exactly one* of your source files do:\n\n```\n#define NBNET_IMPL\n\n#include \"nbnet.h\"\n```\n\nProvide a driver implementation. For instance, for the UDP driver, just add:\n\n```\n#include \"net_drivers/udp.h\"\n```\n\nafter including the nbnet header in the same source file where you defined `NBNET_IMPL`.\n\nnbnet does not provide any logging capabilities so you have to provide your own:\n\n```\n#define NBN_LogInfo(...) SomeLoggingFunction(__VA_ARGS__)\n#define NBN_LogError(...) SomeLoggingFunction(__VA_ARGS__)\n#define NBN_LogDebug(...) SomeLoggingFunction(__VA_ARGS__)\n#define NBN_LogTrace(...) SomeLoggingFunction(__VA_ARGS__)\n#define NBN_LogWarning(...) SomeLoggingFunction(__VA_ARGS__)\n```\n\nFor memory management, nbnet uses `malloc`, `realloc` and `free`. You can redefine them if needed:\n\n```\n#define NBN_Allocator malloc\n#define NBN_Reallocator realloc\n#define NBN_Deallocator free\n```\n\nAll set, from here, I suggest you hop into the examples. If you are interested in WebRTC, go [here](WEBRTC.md).\n\n## Byte arrays\n\nnbnet comes with a primitive bit-level serialization system; but, if you want to use your own serialization solution, nbnet lets you send and receive raw byte arrays.\n\nSee the [echo_bytes](https://github.com/nathhB/nbnet/tree/master/examples/echo_bytes) example.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FnathhB%2Fnbnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FnathhB%2Fnbnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FnathhB%2Fnbnet/lists"}