--- libshout/src/shout.c	Sun Oct  6 14:22:25 2002
+++ libshout.test/src/shout.c	Fri Nov  1 19:58:01 2002
@@ -159,20 +159,24 @@
 	if (!self) 
 		return -1;
 
+	self->error = SHOUTERR_SUCCESS;
 	while(remaining) {
 		ret = sock_write_bytes(self->socket, data, remaining);
-        if(ret < (ssize_t)remaining || errno == EINTR) {
-            remaining -= (ret>0)?ret:0;
-            continue;
-        }
-        else if(ret < 0) {
-            self->error = SHOUTERR_SOCKET;
-            return -1;
+        if (ret == remaining)
+            return len;
+        if(ret < 0)
+        {
+            if (errno == EINTR)
+                ret = 0;
+            else
+            {
+                self->error = SHOUTERR_SOCKET;
+                return -1;
+            }
         }
-        remaining = 0;
+        remaining -= ret;
 	}
 
-	self->error = SHOUTERR_SUCCESS;
 	return len;
 }
 

