Run listener in endless loop
authorKai Blin <kai@samba.org>
Sun, 15 May 2011 09:26:28 +0000 (11:26 +0200)
committerKai Blin <kai@samba.org>
Sun, 15 May 2011 09:26:28 +0000 (11:26 +0200)
listener.c

index 9f7784248e19cf579d0397fe8c0eaa3a6b524fa3..6a836a88e2a45a603300b92f637538d17b960842 100644 (file)
@@ -8,6 +8,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <stdbool.h>
 
 int main(int argc, char **argv)
 {
@@ -34,16 +35,19 @@ int main(int argc, char **argv)
         exit(1);
     }
 
-    msg_len = read(sock6, buf, 1024);
+    while(true) {
+        msg_len = read(sock6, buf, 1024);
 
-    if (msg_len == -1) {
-        perror("receiving data");
-        exit(1);
-    }
+        if (msg_len == -1) {
+            perror("receiving data");
+            exit(1);
+        }
 
-    buf[msg_len] = '\0';
+        buf[msg_len] = '\0';
+
+        printf("--> %s\n", buf);
+    }
 
-    printf("--> %s\n", buf);
     close(sock6);
     return 0;
 }