Bugfix: don't close connection if received bytes are less than buffer size

Closing the connection because the bytes received are less than the buffer size assumes that all the bytes will be received in one go. This is not always true!