Fix remote GPIO hang on macOS #145
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes the issue where
remote_raspi_inithangs indefinitely on macOS when trying to connect to a remote Raspberry Pi.Root Cause:
SDLNet_TCP_Openis a blocking function with no timeout. On macOS, when the host is unreachable, it hangs indefinitely (potentially for minutes due to OS-level TCP timeout settings).Solution: Implement a non-blocking TCP connection with a 5-second timeout using native socket calls:
fcntl()/ioctlsocket()EINPROGRESS)select()with timeout to wait for connectiongetsockopt(SO_ERROR)SDLNet_TCP_Open(which now succeeds immediately)Changes to
network_driver.cpp:fcntl.h,winsock2.h, etc.)SK_CONNECTION_TIMEOUT_SECONDSconstant (5 seconds)_connect_with_timeout()helper functionsk_open_tcp_connection()to use timeout for client connectionsType of change
How Has This Been Tested?
Built and tested on macOS using CMake:
Testing Checklist
Checklist