mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
x/os, os: fix setsockopt on windows, simplify Socket.setOption error set
This commit is contained in:
parent
6cb6edb6f6
commit
6d41e08664
@ -5751,7 +5751,7 @@ pub const SetSockOptError = error{
|
||||
/// Set a socket's options.
|
||||
pub fn setsockopt(fd: socket_t, level: u32, optname: u32, opt: []const u8) SetSockOptError!void {
|
||||
if (builtin.os.tag == .windows) {
|
||||
const rc = windows.ws2_32.setsockopt(fd, level, optname, opt.ptr, @intCast(socklen_t, opt.len));
|
||||
const rc = windows.ws2_32.setsockopt(fd, @intCast(i32, level), @intCast(i32, optname), opt.ptr, @intCast(i32, opt.len));
|
||||
if (rc == windows.ws2_32.SOCKET_ERROR) {
|
||||
switch (windows.ws2_32.WSAGetLastError()) {
|
||||
.WSANOTINITIALISED => unreachable,
|
||||
|
||||
@ -374,8 +374,6 @@ pub fn Mixin(comptime Socket: type) type {
|
||||
.WSAEFAULT => unreachable,
|
||||
.WSAENOTSOCK => return error.FileDescriptorNotASocket,
|
||||
.WSAEINVAL => return error.SocketNotBound,
|
||||
.WSAENOTCONN => return error.SocketNotConnected,
|
||||
.WSAESHUTDOWN => return error.AlreadyShutdown,
|
||||
else => |err| windows.unexpectedWSAError(err),
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user