fix #11
- distinguish new socket and connect
- close socket when connecting