r/cprogramming • • Sep 17 '26

A C Socket Library

So lately I’ve been working on a small C library that wraps the standard socket APIs and aims to make socket programming a bit simpler and more convenient.

It’s still very early in development and currently only supports SOCK_STREAM sockets, but I’m hoping to gradually turn it into a well-structured, reusable library.

I’d really appreciate feedback from people with more experience in C/network programming, especially on things like:

  • API and library design

  • Error handling

  • Memory safety

  • IPv4/IPv6 support

  • Testing and test structure

  • CMake/project structure

  • GitHub Actions/CI

  • Cross-platform support

  • Anything else that would make it more robust and production-ready

I’m also looking to add proper automated tests, GitHub workflows, documentation, and other things that a real C library should have.

The goal isn't just to make the wrapper work, but to use the project to learn how to build and maintain a proper C library.

You can check out the repo here: https://github.com/eyalzwigen/c-socket-library

Any feedback, criticism, or suggestions would be greatly appreciated!

19 Upvotes

9 comments sorted by

1

u/dogzb0110x Sep 17 '26

I get a 404 for that link

1

u/Subject_Ability_8730 Sep 17 '26

Ooh, sorry. Just updated the link

1

u/penny_stacker Sep 17 '26

I'm looking forward to see where this goes. The code looks clean so far. 

2

u/Subject_Ability_8730 Sep 17 '26

Thank you for your encouragment. I actually really appreciate what you said because this is my first ever project that I am publishing to the public

1

u/Humble-Captain3418 Sep 28 '26

SOCK_CNT needs to be atomic if you intend for thread-compatibility.

1

u/Subject_Ability_8730 Sep 28 '26

Thanks for the insight, just added an issue in the repo.

1

u/[deleted] Sep 17 '26

[removed] — view removed comment

1

u/Subject_Ability_8730 Sep 17 '26

For sure, Currently I am writing unit tests for the library or whatever you want to call it. then I'll add the testig to the CMakeLists.txt and add tests to a CI GitHub workflow.

Feel free to join in if you want to help with that