I want to write a http server in zig and I am confused what lib should I use abd how to make a socket.?
Either should it net, os or posix.
Kindly ignore I am missing things. I am new to zig and want to explore this and having a little hard-time because I am coming from python backend development background.
posix is a POSIX compatible API, with limited support for windows.
It is lower level than net, fs, etc.
os has a very short list of cross-platform abstractions which seem to be in limbo, but provides access to submodules for each supported OS e.g. std.os.linux
yes, unless you want to use lower level things such as iouring, kqueue, etc to take advantage of nonblocking io. in that case you would use the OS specific modules.
I want to make a http server and I believe that lower-level things would be better for learning and clarity. This would help me to learn a lot of things about zig.
Be careful here. You are attempting to learn 2 separate (albeit overlapping) domains. Low level things, and Zig.
I would suggest picking one at a time. If your main focus is to get better at Zig (including Allocators, Io), I would suggest sticking to std.net and use the provided higher level abstractions.
That’s not to say that you can’t do both at the same time, just be aware that this will increase the cognitive load as you try to learn specific underlying implementations on top of the language.
Not an answer to your question but as a tip, there’s a http server and client implementation in std.http, which will probably answer a lot of your “How do I do X in Zig?” questions.