Well, the logic here is this.
Based on protocol SFTP can send multiple request and receive back multiple request but it might be not in the same order
so basically I need to track all the requests I m sending and handle them accordingly.
Cause in theory you could simultaneously upload file, get directory and download file, all using the same channel.
I guess what you can do is see if you ever receive a response that does not have a request in the queue.
In theory it should never happen but may be its a case.