| ... | ... | @@ -6644,6 +6644,9 @@ pub const RecvFromError = error{ |
| 6644 | 6644 | |
| 6645 | 6645 | /// The socket is not connected (connection-oriented sockets only). |
| 6646 | 6646 | SocketNotConnected, |
| 6647 | |
| 6648 | /// The other end closed the socket unexpectedly or a read is executed on a shut down socket |
| 6649 | BrokenPipe, |
| 6647 | 6650 | } || UnexpectedError; |
| 6648 | 6651 | |
| 6649 | 6652 | pub fn recv(sock: socket_t, buf: []u8, flags: u32) RecvFromError!usize { |
| ... | ... | @@ -6692,12 +6695,62 @@ pub fn recvfrom( |
| 6692 | 6695 | .CONNREFUSED => return error.ConnectionRefused, |
| 6693 | 6696 | .CONNRESET => return error.ConnectionResetByPeer, |
| 6694 | 6697 | .TIMEDOUT => return error.ConnectionTimedOut, |
| 6698 | .PIPE => return error.BrokenPipe, |
| 6695 | 6699 | else => |err| return unexpectedErrno(err), |
| 6696 | 6700 | } |
| 6697 | 6701 | } |
| 6698 | 6702 | } |
| 6699 | 6703 | } |
| 6700 | 6704 | |
| 6705 | pub const RecvMsgError = RecvFromError || error{ |
| 6706 | /// Reception of SCM_RIGHTS fds via ancillary data in msg.control would |
| 6707 | /// exceed some system limit (generally this is retryable by trying to |
| 6708 | /// receive fewer fds or closing some existing fds) |
| 6709 | SystemFdQuotaExceeded, |
| 6710 | |
| 6711 | /// Reception of SCM_RIGHTS fds via ancillary data in msg.control would |
| 6712 | /// exceed some process limit (generally this is retryable by trying to |
| 6713 | /// receive fewer fds, closing some existing fds, or changing the ulimit) |
| 6714 | ProcessFdQuotaExceeded, |
| 6715 | }; |
| 6716 | |
| 6717 | /// If `sockfd` is opened in non blocking mode, the function will |
| 6718 | /// return error.WouldBlock when EAGAIN is received. |
| 6719 | pub fn recvmsg( |
| 6720 | /// The file descriptor of the sending socket. |
| 6721 | sockfd: socket_t, |
| 6722 | /// Message header and iovecs |
| 6723 | msg: *msghdr, |
| 6724 | flags: u32, |
| 6725 | ) RecvMsgError!usize { |
| 6726 | if (@TypeOf(system.recvmsg) == void) |
| 6727 | @compileError("recvmsg() not supported on this OS"); |
| 6728 | while (true) { |
| 6729 | const rc = system.recvmsg(sockfd, msg, flags); |
| 6730 | switch (errno(rc)) { |
| 6731 | .SUCCESS => return @intCast(rc), |
| 6732 | .AGAIN => return error.WouldBlock, |
| 6733 | .BADF => unreachable, // always a race condition |
| 6734 | .NFILE => return error.SystemFdQuotaExceeded, |
| 6735 | .MFILE => return error.ProcessFdQuotaExceeded, |
| 6736 | .INTR => continue, |
| 6737 | .FAULT => unreachable, // An invalid user space address was specified for an argument. |
| 6738 | .INVAL => unreachable, // Invalid argument passed. |
| 6739 | .ISCONN => unreachable, // connection-mode socket was connected already but a recipient was specified |
| 6740 | .NOBUFS => return error.SystemResources, |
| 6741 | .NOMEM => return error.SystemResources, |
| 6742 | .NOTCONN => return error.SocketNotConnected, |
| 6743 | .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. |
| 6744 | .MSGSIZE => return error.MessageTooBig, |
| 6745 | .PIPE => return error.BrokenPipe, |
| 6746 | .OPNOTSUPP => unreachable, // Some bit in the flags argument is inappropriate for the socket type. |
| 6747 | .CONNRESET => return error.ConnectionResetByPeer, |
| 6748 | .NETDOWN => return error.NetworkSubsystemFailed, |
| 6749 | else => |err| return unexpectedErrno(err), |
| 6750 | } |
| 6751 | } |
| 6752 | } |
| 6753 | |
| 6701 | 6754 | pub const DnExpandError = error{InvalidDnsPacket}; |
| 6702 | 6755 | |
| 6703 | 6756 | pub fn dn_expand( |