add client socket and fix some bugs