Error

Just from a quick glance, you might want to check your client-side GET request: Ask yourself what happens when the file is larger than your packet buffer? Use the debugger or print statements to confirm if your expectations match reality. It might help to do some testing with a really tiny buffer (eg 5 bytes) so you can step through your 21 byte payload easily. What happens when your buffer is smaller than the DONE packet? If your implementation is correct then we would expect that even a 1 byte buffer should work in all cases.

I see a similar code pattern in your server-side PUT request, so if you can solve it for one half, you should be able to fix both.

I lowered the buffersize to 5 and sent the 21 byte test file and it was able to go through. However When I made the buffersize 3 (because my DONE packet was 4 bytes) is hanged and it appended the word DONE without the E.