+- p = strchr(host,'/');
+- if (p) {
+- *p = '\0';
+- path = p+1;
+- } else
+- path = "";
+- if (*host == '[' && (p = strchr(host, ']')) != NULL) {
+- host++;
+- *p++ = '\0';
+- if (*p != ':')
+- p = NULL;
+- } else
+- p = strchr(host, ':');
+- if (p) {
+- rsync_port = atoi(p+1);
+- *p = '\0';
++ /* rsync:// always uses rsync server over direct socket connection */
++ if (strncasecmp(URL_PREFIX, argv[0], url_prefix_len) != 0) {
++#ifdef HAVE_OPENSSL
++ url_prefix_len = sizeof SSL_URL_PREFIX - 1;
++ if (strncasecmp(SSL_URL_PREFIX, argv[0], url_prefix_len) != 0)
++ url_prefix_len = 0;
++ else {
++ if (!use_ssl)
++ init_tls();
++ use_ssl = 1;
++ }
++#else
++ url_prefix_len = 0;
++#endif
++ }
++ if (url_prefix_len) {
++ char *host, *path;
++
++ host = argv[0] + url_prefix_len;
++ p = strchr(host,'/');
++ if (p) {
++ *p = '\0';
++ path = p+1;
++ } else
++ path = "";
++ if (*host == '[' && (p = strchr(host, ']')) != NULL) {
++ host++;
++ *p++ = '\0';
++ if (*p != ':')
++ p = NULL;
++ } else
++ p = strchr(host, ':');
++ if (p) {
++ rsync_port = atoi(p+1);
++ *p = '\0';
++ }
++ return start_socket_client(host, path, argc-1, argv+1);
+ }
+- return start_socket_client(host, path, argc-1, argv+1);
+- }
+
+- if (!read_batch) { /* for read_batch, NO source is specified */
+ p = find_colon(argv[0]);
+ if (p) { /* source is remote */
+ if (remote_filesfrom_file
+@@ -866,12 +884,26 @@ static int start_client(int argc, char *