x/os, os: fix setsockopt on windows, simplify Socket.setOption error set

This commit is contained in:
lithdew 2021-05-09 17:36:35 +09:00
parent 6cb6edb6f6
commit 6d41e08664
2 changed files with 1 additions and 3 deletions

View File

@ -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,

View File

@ -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),
};
}