Sockets communication with a buffer reading more than once