[Live-devel] Suggestion: replace hard-coded errno values with symbolic constants in readSocket()
Николай Исаев
stvdedal at gmail.com
Tue Aug 4 02:22:27 PDT 2026
Hello LIVE555 developers,
While debugging an issue on a Cygwin/Windows build of LIVE555, I noticed
that readSocket() in groupsock/GroupsockHelper.cpp uses hard-coded Linux
errno values:
if (err == 111 /*ECONNREFUSED (Linux)*/
...
|| err == 113 /*EHOSTUNREACH (Linux)*/) {
return 0;
}
Using numeric errno values appears to be fragile across platforms.
On my Cygwin build, I observed:
err = 113
strerror(err) = "Software caused connection abort"
EHOSTUNREACH = 118
As a result, the code treats errno 113 as if it were Linux EHOSTUNREACH,
even though on this platform it represents a different condition. This
caused readSocket() to return 0 instead of propagating the socket error,
leading to a connection that remained active indefinitely.
Would it make sense to replace the hard-coded values with symbolic
constants, e.g.:
if (err == ECONNREFUSED
#if defined(__WIN32__) || defined(_WIN32)
|| err == 0 || err == EWOULDBLOCK
#else
|| err == EAGAIN
#endif
|| err == EHOSTUNREACH) {
return 0;
}
This would avoid assumptions about platform-specific errno numbering and
prevent accidental matches when errno values differ from Linux.
Best regards,
Nikolay Isaev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20260804/371245f0/attachment.htm>
More information about the live-devel
mailing list