Skip to content

Commit

Permalink
Check socket handle for disconnect
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bparks13 committed Mar 8, 2024
1 parent bb4a1e3 commit 929618f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Source/EphysSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 929618f

Please sign in to comment.