Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Network) Check connect errno for successful connection #14420

Merged
merged 1 commit into from
Sep 17, 2022

Conversation

MrHuu
Copy link
Contributor

@MrHuu MrHuu commented Sep 16, 2022

Description

On platforms not supporting getsockopt, use the return value from connect to verify successful socket connection.

Related Issues

Related Pull Requests

Reviewers

@cthulhu-throwaway

@ghost
Copy link

ghost commented Sep 16, 2022

Just checked the implementation on libogc (Wii; GameCube doesn't have networking)... It's an abomination.
It's not compliant with POSIX at all (even Microsoft's connect is more POSIX compliant than this implementation).

  1. It doesn't appear to write anything to errno.
  2. It returns the error constant... as a negative value.

According to this: https://github.com/devkitPro/libogc/blob/bc4b778d558915aa40676e33514c4c9ba2af66b8/libtinysmb/smb.c#L1015-L1022
The gekko (libogc) implementation should be:

   res = connect(fd, addr->ai_addr, addr->ai_addrlen);
   if (res < 0 && -res != EISCONN)
      return false;

net_connect implementation: https://github.com/devkitPro/libogc/blob/bc4b778d558915aa40676e33514c4c9ba2af66b8/libogc/network_wii.c#L850-L871

POSIX clearly states in both POSIX.1-2001 and POSIX.1-2008:

Upon successful completion, connect() shall return 0; otherwise, -1 shall be returned and errno set to indicate the error.

@MrHuu
Copy link
Contributor Author

MrHuu commented Sep 16, 2022

That's wonderful.. I've adapted the logic to reflect this.

@LibretroAdmin LibretroAdmin merged commit dbba69a into libretro:master Sep 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants