Refactorize connectors to use them in client and server