Fixed reading from socket