bug fix(socket.read may return -1)