REF: Socket handling in client