From dbba69a2d14fd33717f59954443204d69aeb747c Mon Sep 17 00:00:00 2001 From: MrHuu Date: Sun, 18 Sep 2022 01:15:09 +0200 Subject: [PATCH] (Network) Check connect errno for successful connection (#14420) --- libretro-common/net/net_socket.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 58497013f6e..ebc49627176 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -728,10 +728,16 @@ bool socket_connect_with_timeout(int fd, void *data, int timeout) return false; } - /* Excluded platforms do not have getsockopt implemented [GEKKO], - * or it's returned values are unreliable [3DS]. - */ -#if !defined(GEKKO) && !defined(_3DS) && defined(SO_ERROR) +#if defined(GEKKO) + /* libogc does not have getsockopt implemented */ + res = connect(fd, addr->ai_addr, addr->ai_addrlen); + if (res < 0 && -res != EISCONN) + return false; +#elif defined(_3DS) + /* libctru getsockopt does not return expected value */ + if (connect(fd, addr->ai_addr, addr->ai_addrlen) < 0 && errno != EISCONN) + return false; +#else { int error = -1; socklen_t errsz = sizeof(error);