| ... | @@ -4276,6 +4276,35 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne | ... | @@ -4276,6 +4276,35 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne |
| 4276 | } | 4276 | } |
| 4277 | } | 4277 | } |
| 4278 | | 4278 | |
| | 4279 | pub const GetSockOptError = error{ |
| | 4280 | /// The calling process does not have the appropriate privileges. |
| | 4281 | AccessDenied, |
| | 4282 | |
| | 4283 | /// The option is not supported by the protocol. |
| | 4284 | InvalidProtocolOption, |
| | 4285 | |
| | 4286 | /// Insufficient resources are available in the system to complete the call. |
| | 4287 | SystemResources, |
| | 4288 | } || UnexpectedError; |
| | 4289 | |
| | 4290 | pub fn getsockopt(fd: socket_t, level: i32, optname: u32, opt: []u8) GetSockOptError!void { |
| | 4291 | var len: socklen_t = undefined; |
| | 4292 | switch (errno(system.getsockopt(fd, level, optname, opt.ptr, &len))) { |
| | 4293 | .SUCCESS => { |
| | 4294 | std.debug.assert(len == opt.len); |
| | 4295 | }, |
| | 4296 | .BADF => unreachable, |
| | 4297 | .NOTSOCK => unreachable, |
| | 4298 | .INVAL => unreachable, |
| | 4299 | .FAULT => unreachable, |
| | 4300 | .NOPROTOOPT => return error.InvalidProtocolOption, |
| | 4301 | .NOMEM => return error.SystemResources, |
| | 4302 | .NOBUFS => return error.SystemResources, |
| | 4303 | .ACCES => return error.AccessDenied, |
| | 4304 | else => |err| return unexpectedErrno(err), |
| | 4305 | } |
| | 4306 | } |
| | 4307 | |
| 4279 | pub fn getsockoptError(sockfd: fd_t) ConnectError!void { | 4308 | pub fn getsockoptError(sockfd: fd_t) ConnectError!void { |
| 4280 | var err_code: i32 = undefined; | 4309 | var err_code: i32 = undefined; |
| 4281 | var size: u32 = @sizeOf(u32); | 4310 | var size: u32 = @sizeOf(u32); |