diff options
| author | Luna <git@l4.pm> | 2019-11-29 17:36:05 -0300 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-12-30 19:26:30 -0500 |
| commit | 0e67568bcac0c4aea795969e2c8b733326b87bec (patch) | |
| tree | e18f13a10540666d7d51d5e0de7208265ab2ad83 | |
| parent | 4a4d2c0d80443a00945beeff4e3acaa9e7ea59cb (diff) | |
| download | zig-0e67568bcac0c4aea795969e2c8b733326b87bec.tar.gz zig-0e67568bcac0c4aea795969e2c8b733326b87bec.zip | |
net: fix Options
- os: fix typos on setsockopt
| -rw-r--r-- | lib/std/net.zig | 4 | ||||
| -rw-r--r-- | lib/std/os.zig | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/std/net.zig b/lib/std/net.zig index effe8e74cd..531900cf96 100644 --- a/lib/std/net.zig +++ b/lib/std/net.zig @@ -1279,6 +1279,7 @@ fn dnsParseCallback(ctx: dpc_ctx, rr: u8, data: []const u8, packet: []const u8) pub const StreamServer = struct { /// Copied from `Options` on `init`. kernel_backlog: u32, + reuse_address: bool, /// `undefined` until `listen` returns successfully. listen_address: Address, @@ -1301,6 +1302,7 @@ pub const StreamServer = struct { return StreamServer{ .sockfd = null, .kernel_backlog = options.kernel_backlog, + .reuse_address = options.reuse_address, .listen_address = undefined, }; } @@ -1323,7 +1325,7 @@ pub const StreamServer = struct { self.sockfd = null; } - if (self.options.reuse_address) { + if (self.reuse_address) { var optval: c_int = 1; try os.setsockopt( self.sockfd.?, diff --git a/lib/std/os.zig b/lib/std/os.zig index 27327c1016..7d20802ba8 100644 --- a/lib/std/os.zig +++ b/lib/std/os.zig @@ -3252,16 +3252,14 @@ pub fn sched_yield() SchedYieldError!void { } /// Set a socket's options. -pub fn setsockopt(fd: fd_t, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) SetSockOptError!void { - const rc = system.setsockopt(); - +pub fn setsockopt(fd: fd_t, level: u32, optname: u32, optval: [*]const u8, optlen: socklen_t) !void { switch (errno(system.setsockopt(fd, level, optname, optval, optlen))) { 0 => {}, EBADF => unreachable, EINVAL => unreachable, EDOM => return error.TimeoutTooBig, EISCONN => return error.AlreadyConnected, - ENOPROTOOOPT => return error.InvalidProtocolOption, + ENOPROTOOPT => return error.InvalidProtocolOption, ENOTSOCK => return error.NotSocket, ENOMEM => return error.OutOfMemory, |
