authorgravatar for bill@axzez.comBill Nagel <bill@axzez.com> 2022-07-13 00:27:32-04:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-07-14 12:51:40+03:00
loga4559271501670b39305fc3575ae8d87fa03d35e
tree316899bf856876e43733886675e65ef0025bc832
parent1653a9b2597c66cbcc88ea75d8a4b88c163584a5

handle HOSTUNREACH for blocking and non-blocking connects


1 files changed, 2 insertions(+), 0 deletions(-)

lib/std/os.zig+2
...@@ -3966,6 +3966,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne...@@ -3966,6 +3966,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne
3966 .FAULT => unreachable, // The socket structure address is outside the user's address space.3966 .FAULT => unreachable, // The socket structure address is outside the user's address space.
3967 .INTR => continue,3967 .INTR => continue,
3968 .ISCONN => unreachable, // The socket is already connected.3968 .ISCONN => unreachable, // The socket is already connected.
3969 .HOSTUNREACH => return error.NetworkUnreachable,
3969 .NETUNREACH => return error.NetworkUnreachable,3970 .NETUNREACH => return error.NetworkUnreachable,
3970 .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket.3971 .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket.
3971 .PROTOTYPE => unreachable, // The socket type does not support the requested communications protocol.3972 .PROTOTYPE => unreachable, // The socket type does not support the requested communications protocol.
...@@ -3995,6 +3996,7 @@ pub fn getsockoptError(sockfd: fd_t) ConnectError!void {...@@ -3995,6 +3996,7 @@ pub fn getsockoptError(sockfd: fd_t) ConnectError!void {
3995 .CONNREFUSED => return error.ConnectionRefused,3996 .CONNREFUSED => return error.ConnectionRefused,
3996 .FAULT => unreachable, // The socket structure address is outside the user's address space.3997 .FAULT => unreachable, // The socket structure address is outside the user's address space.
3997 .ISCONN => unreachable, // The socket is already connected.3998 .ISCONN => unreachable, // The socket is already connected.
3999 .HOSTUNREACH => return error.NetworkUnreachable,
3998 .NETUNREACH => return error.NetworkUnreachable,4000 .NETUNREACH => return error.NetworkUnreachable,
3999 .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket.4001 .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket.
4000 .PROTOTYPE => unreachable, // The socket type does not support the requested communications protocol.4002 .PROTOTYPE => unreachable, // The socket type does not support the requested communications protocol.