fix double socket, refine exceptions