follow-up: AF_UNIX socket enablement: allow path URI to bind address
am: 639e5c89e5

Change-Id: Ib1072a6fc485daaddac5fb6c0cedfd7f71fcf667
diff --git a/upstream/remote-process/README.md b/upstream/remote-process/README.md
index 7341552..768db57 100644
--- a/upstream/remote-process/README.md
+++ b/upstream/remote-process/README.md
@@ -18,6 +18,6 @@
 
 ## Syntax
 
-    remote-process <host> <port> <command>
+    remote-process <hostname port|tcp://[host]:port|unix://path> <command>
 
-You can get all available commands with the `help` command.
\ No newline at end of file
+You can get all available commands with the `help` command.
diff --git a/upstream/remote-process/main.cpp b/upstream/remote-process/main.cpp
index ad94dc3..c0d8f51 100644
--- a/upstream/remote-process/main.cpp
+++ b/upstream/remote-process/main.cpp
@@ -77,19 +77,16 @@
 int usage(const std::string &command, const std::string &error)
 {
     if (not error.empty()) {
-        cerr <<  error << endl;
+        cerr << error << endl;
     }
     cerr << "Usage: " << endl;
     cerr << "Send a single command:" << endl;
     cerr << "\t" << command
-         << " <hostname port|<protocol>://<host:port|port_name>> <command> [argument[s]]" << endl;
+         << " <hostname port|tcp://[host]:port|unix://path> <command> [argument[s]]" << endl;
 
     return 1;
 }
 
-// <hostname port|path> command [argument[s]]
-// or
-// <hostname port|path> < commands
 int main(int argc, char *argv[])
 {
     int commandPos;
@@ -122,24 +119,24 @@
 
             const std::string tcpProtocol{"tcp"};
             const std::string unixProtocol{"unix"};
-            const std::vector<std::string> supportedProtocols{ tcpProtocol, unixProtocol };
+            const std::vector<std::string> supportedProtocols{tcpProtocol, unixProtocol};
             const std::string protocolDelimiter{"://"};
 
             size_t protocolDelPos = endPortArg.find(protocolDelimiter);
             if (protocolDelPos == std::string::npos) {
-                return usage(argv[0], "Invalid socket endpoint, missing " + protocolDelimiter);
+                return usage(argv[0], "Invalid endpoint " + endPortArg);
             }
             protocol = endPortArg.substr(0, protocolDelPos);
 
             if (std::find(begin(supportedProtocols), end(supportedProtocols), protocol) ==
-                    end(supportedProtocols)) {
-                return usage(argv[0], "Invalid socket protocol " + protocol);
+                end(supportedProtocols)) {
+                return usage(argv[0], "Invalid endpoint " + endPortArg);
             }
             isInet = (endPortArg.find(tcpProtocol) != std::string::npos);
             if (isInet) {
-                size_t portDelPos = endPortArg.find(':', protocolDelPos + protocolDelimiter.size());
+                size_t portDelPos = endPortArg.rfind(':');
                 if (portDelPos == std::string::npos) {
-                    return usage(argv[0], "Invalid tcp endpoint" + endPortArg);
+                    return usage(argv[0], "Invalid endpoint " + endPortArg);
                 }
                 host = endPortArg.substr(protocolDelPos + protocolDelimiter.size(),
                                          portDelPos - (protocolDelPos + protocolDelimiter.size()));
diff --git a/upstream/remote-processor/RemoteProcessorServer.cpp b/upstream/remote-processor/RemoteProcessorServer.cpp
index de7447e..8eb709d 100644
--- a/upstream/remote-processor/RemoteProcessorServer.cpp
+++ b/upstream/remote-processor/RemoteProcessorServer.cpp
@@ -61,39 +61,39 @@
         uint16_t port;
         std::string endpointName;
         bool isInet;
+        const std::string expectedForm{"Required: <hostname port|tcp://[host]:port|unix://path>"};
 
         // For backward compatibility, tcp port referred by its value only
         if (convertTo(_bindAddress, port)) {
             isInet = true;
         } else {
-            // required form is <protocol>://<host:port|port_name>
             const std::string tcpProtocol{"tcp"};
             const std::string unixProtocol{"unix"};
-            const std::vector<std::string> supportedProtocols{ tcpProtocol, unixProtocol };
+            const std::vector<std::string> supportedProtocols{tcpProtocol, unixProtocol};
             const std::string protocolDel{"://"};
 
             size_t protocolDelPos = _bindAddress.find(protocolDel);
             if (protocolDelPos == std::string::npos) {
-                error = "bindaddress " + _bindAddress + " ill formed, missing " + protocolDel;
+                error = "bindaddress " + _bindAddress + " invalid, " + expectedForm;
                 return false;
             }
             std::string protocol = _bindAddress.substr(0, protocolDelPos);
 
             if (std::find(begin(supportedProtocols), end(supportedProtocols), protocol) ==
-                    end(supportedProtocols)) {
-                error = "bindaddress " + _bindAddress + " has invalid protocol " + protocol;
+                end(supportedProtocols)) {
+                error = "bindaddress " + _bindAddress + " invalid, " + expectedForm;
                 return false;
             }
             isInet = (_bindAddress.find(tcpProtocol) != std::string::npos);
             if (isInet) {
-                size_t portDelPos = _bindAddress.find(':', protocolDelPos + protocolDel.size());
+                size_t portDelPos = _bindAddress.rfind(':');
                 if (portDelPos == std::string::npos) {
-                    error = "bindaddress " + _bindAddress + " ill formed, missing " + ":";
+                    error = "bindaddress " + _bindAddress + " invalid, " + expectedForm;
                     return false;
                 }
                 std::string portLiteral{_bindAddress.substr(portDelPos + 1)};
                 if (!convertTo(portLiteral, port)) {
-                    error = "bindaddress " + _bindAddress + " port " + portLiteral + " ill formed";
+                    error = "bindaddress " + _bindAddress + " invalid" + expectedForm;
                     return false;
                 }
             } else {