TCP Server in Zig - Part 5b - Poll
Related
More from openmymind.net
I find Zig's idea of a "writer" confusing. This is probably because there are three different types, each trying to compensate for compromises made by the others. Let's try to understand what each is and how it fits into a bigger whole. writer: anytype The first writer that you're likely to run into is a writer: anytype, with the most visible...
One of the first Zig-related blog posts I wrote was an overview of SIMD with Zig. I recently needed to revisit this topic when enhancing my smtp client library. Specifically, SMTP mostly expects printable ASCII characters. Almost all other characters, including UTF-8 text, must be encoded. I found the various SMTP and MIME RFCs confusing. So I...
Zig doesn't have an interface keyword or some simple way to create interfaces. Nonetheless, types like std.mem.Allocator and std.Random are often cited as examples that, with a bit of elbow grease, Zig offers every thing needed to create them. We've looked at Zig Interfaces in the past. If you want to understand how they work and how to write...
If you look at my httpz library, you'll notice that httpz.Server(T) is a generic. The type passed to Server serves two purposes. The first is to support an application-specific context - whatever instance of T passed into Server(T).init gets passed back to your custom HTTP handlers. But the other purpose of T is to act as a configuration object....
In an older post, we explored Zig's @ptrCast and then looked at a concrete usage in the shape of std.heap.MemoryPool. @ptrCast As a brief recap, when we use @ptrCast, we're telling the compiler to treat a pointer as a given type. For example, this code runs fine: const std = @import("std"); pub fn main() !void { var user = User{.power = 9001,...