restructure client-side socket setup; fixes #12