fixed socket read bugs