This adds support for <address>:<port> in the rrd client library.
[rrdtool.git] / src / rrd_client.c
index 11fb80d..c573dad 100644 (file)
@@ -352,6 +352,7 @@ static int rrdc_connect_network (const char *addr) /* {{{ */
   struct addrinfo ai_hints;
   struct addrinfo *ai_res;
   struct addrinfo *ai_ptr;
+  char *port;
 
   assert (addr != NULL);
   assert (sd == -1);
@@ -365,8 +366,14 @@ static int rrdc_connect_network (const char *addr) /* {{{ */
   ai_hints.ai_family = AF_UNSPEC;
   ai_hints.ai_socktype = SOCK_STREAM;
 
+  port = rindex(addr, ':');
+  if (port != NULL)
+    *port++ = '\0';
+
   ai_res = NULL;
-  status = getaddrinfo (addr, RRDCACHED_DEFAULT_PORT, &ai_hints, &ai_res);
+  status = getaddrinfo (addr,
+                        port == NULL ? RRDCACHED_DEFAULT_PORT : port,
+                        &ai_hints, &ai_res);
   if (status != 0)
     return (status);