diff options
| author | Luna <git@l4.pm> | 2019-11-29 17:17:09 -0300 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-12-30 19:26:29 -0500 |
| commit | 4a4d2c0d80443a00945beeff4e3acaa9e7ea59cb (patch) | |
| tree | bcb4f1f7202f51f03d6f40a1df295e952533f71b /lib/std/net.zig | |
| parent | 631eb6783d1dbc64f031426436ab685008c31ca8 (diff) | |
| download | zig-4a4d2c0d80443a00945beeff4e3acaa9e7ea59cb.tar.gz zig-4a4d2c0d80443a00945beeff4e3acaa9e7ea59cb.zip | |
os: add setsockopt
- net: use os.setsockopt()
Diffstat (limited to 'lib/std/net.zig')
| -rw-r--r-- | lib/std/net.zig | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/std/net.zig b/lib/std/net.zig index cd456c46c6..effe8e74cd 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -1323,14 +1323,12 @@ pub const StreamServer = struct { self.sockfd = null; } - // TODO proper interface with errors in std.os - var optval: c_int = 1; - if (self.options.reuse_address) { - _ = os.linux.setsockopt( - server.sockfd.?, - os.linux.SOL_SOCKET, - os.linux.SO_REUSEADDR, + var optval: c_int = 1; + try os.setsockopt( + self.sockfd.?, + os.SOL_SOCKET, + os.SO_REUSEADDR, @ptrCast([*]const u8, &optval), @sizeOf(c_int), ); |
