summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMax Krasnyansky <maxk@qualcomm.com>2002-10-15 17:44:49 +0000
committerMax Krasnyansky <maxk@qualcomm.com>2002-10-15 17:44:49 +0000
commitd774efc2f8cc21d599cacc933ea26e0d63e91365 (patch)
tree4a62a0a5b5a7b6db8c6c8e24b0e8df3fc791c6df /test
parentb5edb3c0a92674b27a95f7968e18bb51150c52f6 (diff)
Use select in dump mode.
Diffstat (limited to 'test')
-rw-r--r--test/l2test.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/l2test.c b/test/l2test.c
index b08b2d34..53e9e768 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -35,6 +35,7 @@
#include <string.h>
#include <errno.h>
#include <signal.h>
+#include <sys/select.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -236,8 +237,24 @@ void dump_mode(int s)
int len;
syslog(LOG_INFO, "Receiving ...");
- while ((len = read(s, buf, data_size)) > 0)
+ while (1) {
+ fd_set rset;
+
+ FD_ZERO(&rset);
+ FD_SET(s, &rset);
+
+ if (select(s + 1, &rset, NULL, NULL, NULL) < 0)
+ return;
+
+ if (!FD_ISSET(s, &rset))
+ continue;
+
+ len = read(s, buf, data_size);
+ if (len <= 0)
+ return;
+
syslog(LOG_INFO, "Recevied %d bytes\n", len);
+ }
}
void recv_mode(int s)