  
     key.data = cmd->data.list[0];
 diff --git a/gmetad/data_thread.c b/gmetad/data_thread.c
-index e5707d7..ab54e14 100644
+index 55818fa..a9dc57d 100644
 --- a/gmetad/data_thread.c
 +++ b/gmetad/data_thread.c
+@@ -24,7 +24,7 @@ data_thread ( void *arg )
+ {
+    int i, bytes_read, rval;
+    data_source_list_t *d = (data_source_list_t *)arg;
+-   g_inet_addr *addr;
++   g_inet6_addr *addr;
+    g_tcp_socket *sock=0;
+    datum_t key;
+    char *buf;
 @@ -68,7 +68,7 @@ data_thread ( void *arg )
           
           /* If we successfully read from a good data source last time then try the same host again first. */

 
                if (riemann_udp_socket == NULL)
                   err_quit("[riemann] %s socket failed for %s:%d", c->riemann_protocol, c->riemann_server, c->riemann_port);
             } else if (!strcmp(c->riemann_protocol, "tcp")) {
-                riemann_tcp_socket = init_riemann_tcp_socket (c->riemann_server, c->riemann_port);
+                riemann_tcp_socket = init_riemann_tcp6_socket (c->riemann_server, c->riemann_port);
                 if (riemann_tcp_socket == NULL) {
                    riemann_circuit_breaker = RIEMANN_CB_OPEN;
                    riemann_reset_timeout = apr_time_now () + RIEMANN_RETRY_TIMEOUT * APR_USEC_PER_SEC;
diff --git a/gmetad/gmetad.conf.in b/gmetad/gmetad.conf.in
index a29081b..cfbcbec 100644
--- a/gmetad/gmetad.conf.in
+++ b/gmetad/gmetad.conf.in
@@ -40,6 +40,7 @@

                    {
                      d->last_good_index = i;
diff --git a/gmetad/export_helpers.c b/gmetad/export_helpers.c
index cf05c51..811114a 100644
--- a/gmetad/export_helpers.c
+++ b/gmetad/export_helpers.c
@@ -16,6 +16,7 @@
 #include <netdb.h>
 #include <sys/poll.h>
 #include <arpa/inet.h>
+#include <netdb.h>
 
 #ifdef WITH_MEMCACHED
 #include <libmemcached-1.0/memcached.h>
@@ -28,6 +29,7 @@
 
 #include "export_helpers.h"
 
+#define MAX_PORT_LEN 6
 #define PATHSIZE 4096
 extern gmetad_config_t gmetad_config;
 
@@ -97,6 +99,55 @@ init_riemann_udp_socket (const char *hostname, uint16_t port)
 
    return s;
 }
+
+g_udp_socket*
+init_riemann_udp6_socket (const char *hostname, uint16_t port)
+{
