Open tmm1 opened 6 years ago
I've seen and used the "call connect() again after poll/select" pattern before, which is why I implemented it here.
But according to the linux connect(2) man page, another alternative is to use getsockopt to get the connection status:
After select(2) indicates writability, use getsockopt(2) to read the
SO_ERROR option at level SOL_SOCKET to determine whether
connect() completed successfully (SO_ERROR is zero) or
unsuccessfully (SO_ERROR is one of the usual error codes
listed here, explaining the reason for the failure).
Makes sure that errno is set correctly after hdhomerun_sock_connect returns, which makes it possible for the caller to notify the user about the exact error condition.