libhdhomerun icon indicating copy to clipboard operation
libhdhomerun copied to clipboard

Ensure that errno is set correctly after hdhomerun_sock_connect

Open tmm1 opened this issue 7 years ago • 1 comments

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.

tmm1 avatar Sep 28 '18 01:09 tmm1

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).

tmm1 avatar Sep 28 '18 02:09 tmm1