The code tests if res < 0 so the res = 0 will always fail, and WSAEWOULDBLOCK sleep never happens
// get the data
res := socket.Recv((PByte(IoBuffer) + cbData), cbIoBufferLength - cbData);
if res < 0 then
begin
if (res = 0) and (WSAGetLastError = WSAEWOULDBLOCK) then
begin
Sleep(100);
Continue;
end;
raise ESSPIError.CreateWinAPI('reading data from server', 'recv', res);
end
The code tests if res < 0 so the res = 0 will always fail, and WSAEWOULDBLOCK sleep never happens