this repo has no description
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

mac: use std.c for setsockopt

zig 0.13.0 doesn't expose the proper macOS wrappers for setsockopt. Use
the lower level std.c interfaces.

+19 -9
+19 -9
src/irc.zig
··· 2138 2138 pub fn configureKeepalive(self: *Client) !void { 2139 2139 const sock = self.stream.handle; 2140 2140 2141 - const posix = std.posix; 2142 - const enable = std.mem.toBytes(@as(i32, 1)); 2143 - try posix.setsockopt(sock, posix.SOL.SOCKET, posix.SO.KEEPALIVE, &enable); 2141 + const os = std.c; 2142 + const size = @sizeOf(i32); 2144 2143 2145 - const idle = std.mem.toBytes(@as(i32, 10)); // 10 seconds 2146 - try posix.setsockopt(sock, posix.IPPROTO.TCP, posix.TCP.KEEPIDLE, &idle); 2144 + const enable: i32 = 1; 2145 + if (os.setsockopt(sock, os.SOL.SOCKET, os.SO.KEEPALIVE, &enable, size) != 0) { 2146 + return error.SetSockOptError; 2147 + } 2147 2148 2148 - const interval = std.mem.toBytes(@as(i32, 5)); // 5 seconds 2149 - try posix.setsockopt(sock, posix.IPPROTO.TCP, posix.TCP.KEEPINTVL, &interval); 2149 + const idle: i32 = 10; // 10 seconds 2150 + if (os.setsockopt(sock, os.IPPROTO.TCP, os.TCP.KEEPIDLE, &idle, size) != 0) { 2151 + return error.SetSockOptError; 2152 + } 2150 2153 2151 - const count = std.mem.toBytes(@as(i32, 3)); // 3 probes before closing 2152 - try posix.setsockopt(sock, posix.IPPROTO.TCP, posix.TCP.KEEPCNT, &count); 2154 + const interval: i32 = 5; // 5 seconds 2155 + if (os.setsockopt(sock, os.IPPROTO.TCP, os.TCP.KEEPINTVL, &interval, size) != 0) { 2156 + return error.SetSockOptError; 2157 + } 2158 + 2159 + const count: i32 = 3; // 3 probes before closing 2160 + if (os.setsockopt(sock, os.IPPROTO.TCP, os.TCP.KEEPCNT, &count, size) != 0) { 2161 + return error.SetSockOptError; 2162 + } 2153 2163 } 2154 2164 2155 2165 pub fn getOrCreateChannel(self: *Client, name: []const u8) Allocator.Error!*Channel {