diff --git a/Listener.cpp b/Listener.cpp index be95abd6..7190cb53 100644 --- a/Listener.cpp +++ b/Listener.cpp @@ -16,6 +16,7 @@ CListener::~CListener() { bool CListener::Listen() { if (!m_uPort || m_pListener) { + errno = EINVAL; return false; } @@ -29,6 +30,10 @@ bool CListener::Listen() { } #endif + // If e.g. getaddrinfo() fails, the following might not set errno. + // Make sure there is a consistent error message, not something random + // which might even be "Error: Success". + errno = EINVAL; return CZNC::Get().GetManager().ListenHost(m_uPort, "_LISTENER", m_sBindHost, bSSL, SOMAXCONN, m_pListener, 0, m_eAddr); }