First, you don't need to flush the socket every time through the loop. Once after the loop would be fine. Second, why such a big buffersize? Puts will increase the buffer as it needs it, so you shouldn't need to set such a big one initially. Third, the problem could easily be somewhere else. Where d...