diff --git a/include/icsneo/platform/socket.h b/include/icsneo/platform/socket.h index 63895a1d..2c2013d4 100644 --- a/include/icsneo/platform/socket.h +++ b/include/icsneo/platform/socket.h @@ -137,6 +137,9 @@ public: if (::poll(&pfd, 1, static_cast(timeout.count())) == -1) { return false; } + if (pfd.revents & (POLLHUP | POLLERR)) { + return false; + } in = pfd.revents & POLLIN; return true; #endif @@ -155,7 +158,12 @@ public: } bool send(const void* buffer, size_t size) { - auto sent = ::send(mFD, (const char*)buffer, (int)size, 0); + #ifdef _WIN32 + int flags = 0; + #else + int flags = MSG_NOSIGNAL; + #endif + auto sent = ::send(mFD, (const char*)buffer, (int)size, flags); if(sent == -1) { return false; } diff --git a/platform/servd.cpp b/platform/servd.cpp index c3ffb614..00587fe7 100644 --- a/platform/servd.cpp +++ b/platform/servd.cpp @@ -113,6 +113,10 @@ bool Servd::open() { return false; } const auto tokens = split(response); + if(tokens.size() == 1 && tokens[0] == "0") { + EventManager::GetInstance().add(APIEvent::Type::DeviceDisconnected, APIEvent::Severity::Error); + return false; + } if(tokens.size() != 2) { EventManager::GetInstance().add(APIEvent::Type::ServdInvalidResponseError, APIEvent::Severity::Error); return false;