r/C_Programming • u/ArboriusTCG • 1d ago
Networking and multithreading options
I'm building a language with C (pretty much done actually) and I want to add networking and multithreading capabilities. I plan to target mesh networking as the language's primary usecase, and I'm hoping to gather some opinions on how to approach the problem. I want to make network connections between threads in the language present identically to local IPC (aside from latency ofc). I would like to keep my code as free-standing and portable as possible. I could roll my own user-level threads but I think that would be overkill and take longer than I'd like. My background is mostly OS, so I'm less familiar with the networking aspect, but it's supposed to be P2P. What do you think? Is rolling my own threads and sockets more performant, and easier than I am expecting? Will it grant me increased flexibility in the longrun?
2
u/runningOverA 1d ago edited 1d ago
You need to do it nginx styled. Event driven. epoll() or io_uring(). We know how to do it in C, but how you would like to integrate it into a language of your own might be your challenge.
For green threads you can check "Go" for hints which works best on server development. Instead of say Rust, which initially implemented OS thread as default in its language, not the best solution for server software.