Index: trunk/Ohana/src/opihi/lib.data/IOBufferOps.c
===================================================================
--- trunk/Ohana/src/opihi/lib.data/IOBufferOps.c	(revision 4693)
+++ trunk/Ohana/src/opihi/lib.data/IOBufferOps.c	(revision 4697)
@@ -1,3 +1,3 @@
-# include "pclient.h"
+# include "data.h"
 
 int InitIOBuffer (IOBuffer *buffer, int Nalloc) {
@@ -61,4 +61,19 @@
 }
 
+/* read until buffer is empty (Nmax retries) */
+int EmptyIOBuffer (IOBuffer *buffer, int Nmax, int fd) {
+
+  int i, status;
+
+  status = -1;
+  for (i = 0; (status != 0) && (i < Nmax); i++) {
+    status = ReadtoIOBuffer (buffer, fd);
+    if (status == -1) usleep (10000);
+    if (status > 0) i = 0;
+  }
+  if (status == -1) return (FALSE);
+  return (TRUE);
+}
+
 void FreeIOBuffer (IOBuffer *buffer) {
 
