ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
33.58k stars 2.45k forks source link

Guidelines on writing networking clients #2814

Open kristoff-it opened 5 years ago

kristoff-it commented 5 years ago

Since we are nearing #1778, there are going to be a lot of clients that need to be written (e.g. http #2007), and since I suspect more and more people are coming to Zig from higher-level languages, like me, I think it would be useful to have a short list of resources / guidelines on writing clients in Zig.

I'm personally interested in writing a Redis client for Zig but I only have cursory experience in writing parsers + networking.

I recently read a bit about streaming and sans i/o parsers, but I'd like to get more pointers on the subject from people more experienced in systems programming.

I'm sure that many of these concepts are worth applying to most (if not all) networking clients so keeping a list somewhere would prove useful to many.

kristoff-it commented 5 years ago

One example: https://sans-io.readthedocs.io/

(whether this should be considered a good suggestion or not, is to be decided)

ikskuh commented 5 years ago

The idea behind Sans I/O sounds reasonable. Imagine someone wants to use Zig on an embedded platform and can just adjust the HTTP client to use its embedded TCP/IP stack instead of having to rewrite it over and over again just because the standard library "enforces" the posix network layer or such

xylobol commented 3 months ago

Imagine someone wants to use Zig on an embedded platform and can just adjust the HTTP client to use its embedded TCP/IP stack instead of having to rewrite it over and over again just because the standard library "enforces" the posix network layer or such

This is sort of what I'm running into now - new OS, new networking stack. Currently, I have to have a fork of the standard library that supports this, compared to just defining a separate stream implementation and passing this into the HTTP client implementation.