Commit 6d41e08664

lithdew <kenta@lithdew.net>
2021-05-09 10:36:35
x/os, os: fix setsockopt on windows, simplify Socket.setOption error set
1 parent 6cb6edb
Changed files (2)
lib/std/x/os/socket_windows.zig
@@ -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),
                 };
             }
lib/std/os.zig
@@ -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,