diff --git a/SelectableCore.cpp b/SelectableCore.cpp index ce7daf4..b853979 100644 --- a/SelectableCore.cpp +++ b/SelectableCore.cpp @@ -1130,12 +1130,30 @@ bool CSelectableCore::Read( THandle * Handle ) ioctl( Handle->FD, FIONREAD, &BytesWaiting ); // EOF from server - if (!BytesWaiting) + if (BytesWaiting < 1) { // Close Handle Close( Handle ); - // Destroy Remote Client + // Destroy Client + if (Handle->Type == ctRemoteClient) { + RemoveHandle( Handle ); + } + return false; + } + } + else if (Handle->Type == ctPort) + { + // Check if anything to read + ioctl( Handle->FD, FIONREAD, &BytesWaiting ); + + // EOF from port + if (BytesWaiting < 1) + { + // Close Handle + Close( Handle ); + + // Destroy Port if (Handle->Type == ctRemoteClient) { RemoveHandle( Handle ); }