From 929618fdec15c69019d9de0ebe333afbafedd96e Mon Sep 17 00:00:00 2001 From: Brandon Parks Date: Fri, 8 Mar 2024 13:11:00 -0500 Subject: [PATCH] Check socket handle for disconnect If the remote server disconnects, the read call will block, meaning the thread will not end when expected. Once the socket is shutdown, the call will return with an invalid handle, which can be caught and returned correctly --- Source/EphysSocket.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/EphysSocket.cpp b/Source/EphysSocket.cpp index 056d7d5..a0d502c 100644 --- a/Source/EphysSocket.cpp +++ b/Source/EphysSocket.cpp @@ -264,6 +264,12 @@ void EphysSocket::runBufferThread() if (rc == -1) { + if (socket->getRawSocketHandle() == -1) + { + CoreServices::sendStatusMessage("Ephys Socket: Socket handle is no longer valid."); + return; + } + CoreServices::sendStatusMessage("Ephys Socket: Data shape mismatch"); error_flag = true; return;