connect and disconnect from server