update client2.js

move client connect and close function inside the client module.