Skip to content

Commit

Permalink
(Network) Check connect errno for successful connection
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHuu committed Sep 16, 2022
1 parent 83ce6f4 commit 29bfd71
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions libretro-common/net/net_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
#elif defined(SO_ERROR)
{
int error = -1;
socklen_t errsz = sizeof(error);
Expand Down

0 comments on commit 29bfd71

Please sign in to comment.