mirror of
https://github.com/ziglang/zig.git
synced 2024-11-15 16:45:27 +00:00
net: fix Options
- os: fix typos on setsockopt
This commit is contained in:
parent
4a4d2c0d80
commit
0e67568bca
@ -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.?,
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user