diff --git a/lib/std/posix.zig b/lib/std/posix.zig index 815d2894e9..c3172dba4d 100644 --- a/lib/std/posix.zig +++ b/lib/std/posix.zig @@ -4285,6 +4285,9 @@ pub const ConnectError = error{ /// Socket is non-blocking and already has a pending connection in progress. ConnectionPending, + + /// Socket was already connected + AlreadyConnected, } || UnexpectedError; /// Initiate a connection on a socket. @@ -4305,7 +4308,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne => return error.NetworkUnreachable, .WSAEFAULT => unreachable, .WSAEINVAL => unreachable, - .WSAEISCONN => unreachable, + .WSAEISCONN => return error.AlreadyConnected, .WSAENOTSOCK => unreachable, .WSAEWOULDBLOCK => return error.WouldBlock, .WSAEACCES => unreachable, @@ -4331,7 +4334,7 @@ pub fn connect(sock: socket_t, sock_addr: *const sockaddr, len: socklen_t) Conne .CONNRESET => return error.ConnectionResetByPeer, .FAULT => unreachable, // The socket structure address is outside the user's address space. .INTR => continue, - .ISCONN => unreachable, // The socket is already connected. + .ISCONN => return error.AlreadyConnected, // The socket is already connected. .HOSTUNREACH => return error.NetworkUnreachable, .NETUNREACH => return error.NetworkUnreachable, .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket. @@ -4391,7 +4394,7 @@ pub fn getsockoptError(sockfd: fd_t) ConnectError!void { .BADF => unreachable, // sockfd is not a valid open file descriptor. .CONNREFUSED => return error.ConnectionRefused, .FAULT => unreachable, // The socket structure address is outside the user's address space. - .ISCONN => unreachable, // The socket is already connected. + .ISCONN => return error.AlreadyConnected, // The socket is already connected. .HOSTUNREACH => return error.NetworkUnreachable, .NETUNREACH => return error.NetworkUnreachable, .NOTSOCK => unreachable, // The file descriptor sockfd does not refer to a socket.