mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
std.posix: handle ENOTCONN for getpeername
This commit is contained in:
parent
d73fbcc3ae
commit
a8b516fdaa
1 changed files with 5 additions and 0 deletions
|
|
@ -3635,6 +3635,9 @@ pub const GetSockNameError = error{
|
||||||
SocketNotBound,
|
SocketNotBound,
|
||||||
|
|
||||||
FileDescriptorNotASocket,
|
FileDescriptorNotASocket,
|
||||||
|
|
||||||
|
/// The socket is not connected (connection-oriented sockets only).
|
||||||
|
SocketUnconnected,
|
||||||
} || UnexpectedError;
|
} || UnexpectedError;
|
||||||
|
|
||||||
pub fn getsockname(sock: socket_t, addr: *sockaddr, addrlen: *socklen_t) GetSockNameError!void {
|
pub fn getsockname(sock: socket_t, addr: *sockaddr, addrlen: *socklen_t) GetSockNameError!void {
|
||||||
|
|
@ -3676,6 +3679,7 @@ pub fn getpeername(sock: socket_t, addr: *sockaddr, addrlen: *socklen_t) GetSock
|
||||||
.EFAULT => unreachable, // addr or addrlen have invalid pointers or addrlen points to an incorrect value
|
.EFAULT => unreachable, // addr or addrlen have invalid pointers or addrlen points to an incorrect value
|
||||||
.ENOTSOCK => return error.FileDescriptorNotASocket,
|
.ENOTSOCK => return error.FileDescriptorNotASocket,
|
||||||
.EINVAL => return error.SocketNotBound,
|
.EINVAL => return error.SocketNotBound,
|
||||||
|
.ENOTCONN => return error.SocketUnconnected,
|
||||||
else => |err| return windows.unexpectedWSAError(err),
|
else => |err| return windows.unexpectedWSAError(err),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3691,6 +3695,7 @@ pub fn getpeername(sock: socket_t, addr: *sockaddr, addrlen: *socklen_t) GetSock
|
||||||
.INVAL => unreachable, // invalid parameters
|
.INVAL => unreachable, // invalid parameters
|
||||||
.NOTSOCK => return error.FileDescriptorNotASocket,
|
.NOTSOCK => return error.FileDescriptorNotASocket,
|
||||||
.NOBUFS => return error.SystemResources,
|
.NOBUFS => return error.SystemResources,
|
||||||
|
.NOTCONN => return error.SocketUnconnected,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue