Index: memcache/apr_memcache.c
===================================================================
--- memcache/apr_memcache.c	(revision 28)
+++ memcache/apr_memcache.c	(working copy)
@@ -15,6 +15,7 @@
 
 #include "apr_memcache.h"
 #include "apr_version.h"
+#include "apr_buckets.h"
 #include <stdlib.h>
 
 #if APR_MAJOR_VERSION < 1
@@ -99,6 +100,35 @@
 #define MS_END "END"
 #define MS_END_LEN (sizeof(MS_END)-1)
 
+static apr_status_t apr_memcache_sendv(apr_socket_t *sock, const struct iovec *vec, apr_int32_t nvec)
+{
+    apr_int32_t i;
+
+    for (i = 0; i < nvec; i++) {
+        char *buf;
+        apr_size_t len;
+        apr_status_t rv;
+
+        buf = vec[i].iov_base;
+        len = vec[i].iov_len;
+
+        while (0 < len) {
+            apr_size_t written = len;
+
+            rv = apr_socket_send(sock, buf, &written);
+
+            if (rv != APR_SUCCESS) {
+                /* fatal error */
+                return rv;
+            }
+
+            buf += written;
+            len -= written;
+        }
+    }
+
+    return APR_SUCCESS;
+}
 
 static apr_status_t make_server_dead(apr_memcache_t * mc, apr_memcache_server_t * ms)
 {
@@ -459,7 +489,7 @@
 
 static apr_status_t get_server_line(apr_memcache_conn_t* conn)
 {
-    int bsize = BUFFER_SIZE;
+    apr_size_t bsize = BUFFER_SIZE;
     apr_status_t rv = APR_SUCCESS;
 
     rv = apr_brigade_split_line(conn->tb, conn->bb, APR_BLOCK_READ, BUFFER_SIZE);
@@ -498,7 +528,6 @@
     apr_memcache_server_t* ms;
     apr_memcache_conn_t* conn;
     apr_status_t rv;
-    apr_size_t written;
     struct iovec vec[5];
     int klen;
 
@@ -537,7 +566,7 @@
     vec[4].iov_base = MC_EOL;
     vec[4].iov_len  = MC_EOL_LEN;
 
-    rv = apr_socket_sendv(conn->sock, vec, 5, &written);
+    rv = apr_memcache_sendv(conn->sock, vec, 5);
 
     if (rv != APR_SUCCESS) {
         ms_bad_conn(ms, conn);
@@ -626,7 +655,6 @@
     apr_memcache_server_t* ms;
     apr_memcache_conn_t* conn;
     apr_uint32_t hash;
-    apr_size_t written;
     int klen = strlen(key);
     struct iovec vec[3];
 
@@ -652,7 +680,7 @@
     vec[2].iov_base = MC_EOL;
     vec[2].iov_len  = MC_EOL_LEN;
 
-    rv = apr_socket_sendv(conn->sock, vec, 3, &written);
+    rv = apr_memcache_sendv(conn->sock, vec, 3);
 
     if (rv != APR_SUCCESS) {
         ms_bad_conn(ms, conn);
@@ -672,7 +700,7 @@
         char *length;
         char *start;
         char *last;
-        apr_uint32_t len;
+        apr_size_t len;
 
         start = conn->buffer;
         flags = apr_strtok(conn->buffer," ",&last);
@@ -756,7 +784,6 @@
     apr_memcache_server_t* ms;
     apr_memcache_conn_t* conn;
     apr_uint32_t hash;
-    apr_size_t written;
     struct iovec vec[3];
     int klen = strlen(key);
 
@@ -784,7 +811,7 @@
     vec[2].iov_base = conn->buffer;
     vec[2].iov_len  = klen;
 
-    rv = apr_socket_sendv(conn->sock, vec, 3, &written);
+    rv = apr_memcache_sendv(conn->sock, vec, 3);
 
     if (rv != APR_SUCCESS) {
         ms_bad_conn(ms, conn);
@@ -825,7 +852,6 @@
     apr_memcache_server_t* ms;
     apr_memcache_conn_t* conn;
     apr_uint32_t hash;
-    apr_size_t written;
     struct iovec vec[3];
     int klen = strlen(key);
 
@@ -853,7 +879,7 @@
     vec[2].iov_base = conn->buffer;
     vec[2].iov_len  = klen;
 
-    rv = apr_socket_sendv(conn->sock, vec, 3, &written);
+    rv = apr_memcache_sendv(conn->sock, vec, 3);
 
     if (rv != APR_SUCCESS) {
         ms_bad_conn(ms, conn);
@@ -923,7 +949,6 @@
 {
     apr_status_t rv;
     apr_memcache_conn_t* conn;
-    apr_size_t written;
     struct iovec vec[2];
 
     rv = ms_find_conn(ms, &conn);
@@ -939,7 +964,7 @@
     vec[1].iov_base = MC_EOL;
     vec[1].iov_len  = MC_EOL_LEN;
 
-    rv = apr_socket_sendv(conn->sock, vec, 2, &written);
+    rv = apr_memcache_sendv(conn->sock, vec, 2);
 
     if (rv != APR_SUCCESS) {
         ms_bad_conn(ms, conn);
@@ -969,7 +994,6 @@
 apr_status_t mc_version_ping(apr_memcache_server_t *ms)
 {
     apr_status_t rv;
-    apr_size_t written;
     struct iovec vec[2];
     apr_memcache_conn_t* conn;
 
@@ -986,7 +1010,7 @@
     vec[1].iov_base = MC_EOL;
     vec[1].iov_len  = MC_EOL_LEN;
 
-    rv = apr_socket_sendv(conn->sock, vec, 2, &written);
+    rv = apr_memcache_sendv(conn->sock, vec, 2);
 
     if (rv != APR_SUCCESS) {
         ms_bad_conn(ms, conn);
@@ -1176,7 +1200,6 @@
     apr_memcache_stats_t *ret;
     apr_status_t rv;
     apr_memcache_conn_t* conn;
-    apr_size_t written;
     struct iovec vec[2];
 
     rv = ms_find_conn(ms, &conn);
@@ -1192,7 +1215,7 @@
     vec[1].iov_base = MC_EOL;
     vec[1].iov_len  = MC_EOL_LEN;
 
-    rv = apr_socket_sendv(conn->sock, vec, 2, &written);
+    rv = apr_memcache_sendv(conn->sock, vec, 2 );
 
     if (rv != APR_SUCCESS) {
         ms_bad_conn(ms, conn);
Index: memcache/apr_memcache.h
===================================================================
--- memcache/apr_memcache.h	(revision 28)
+++ memcache/apr_memcache.h	(working copy)
@@ -30,7 +30,6 @@
 #include "apr_strings.h"
 #include "apr_network_io.h"
 #include "apr_ring.h"
-#include "apr_buckets.h"
 #include "apr_reslist.h"
 
 #ifdef __cplusplus
