Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions lib/std/posix.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6577,6 +6577,36 @@ pub fn recvfrom(
}
}

pub const RecvMsgError = error{
InputOutput,
} || RecvFromError;

pub fn recvmsg(sockfd: socket_t, msg: *msghdr, flags: u32) RecvMsgError!usize {
while (true) {
const rc = system.recvmsg(sockfd, msg, flags);
switch (errno(rc)) {
.SUCCESS => return @intCast(rc),

.AGAIN => return error.WouldBlock,
.CONNREFUSED => return error.ConnectionRefused,
.CONNRESET => return error.ConnectionResetByPeer,
.IO => return error.InputOutput,
.MSGSIZE => return error.MessageTooBig,
.NOBUFS => return error.SystemResources,
.NOMEM => return error.SystemResources,
.NOTCONN => return error.SocketNotConnected,
.TIMEDOUT => return error.ConnectionTimedOut,
.INTR => continue,
.BADF => unreachable,
.FAULT => unreachable,
.INVAL => unreachable,
.NOTSOCK => unreachable, // the socket descriptor does not refer to a socket
.OPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type.
else => |err| return unexpectedErrno(err),
}
}
}

pub const DnExpandError = error{InvalidDnsPacket};

pub fn dn_expand(
Expand Down