fix some socket bugs.