From 13698a983ab7e44e523f1b914c56dc0bbe883c4f Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 11 Oct 2015 16:21:22 +0200 Subject: [PATCH] Clarify read/write direction in test program. --- test.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test.c b/test.c index 75fce79..8ad46c6 100644 --- a/test.c +++ b/test.c @@ -13,8 +13,11 @@ #include "utcp.h" +#define DIR_READ 1 +#define DIR_WRITE 2 + struct utcp_connection *c; -int dir = 3; +int dir = DIR_READ | DIR_WRITE; bool running = true; double dropin; double dropout; @@ -25,7 +28,7 @@ ssize_t do_recv(struct utcp_connection *c, const void *data, size_t len) { fprintf(stderr, "Error: %s\n", strerror(errno)); dir = 0; } else { - dir &= ~2; + dir &= ~DIR_WRITE; fprintf(stderr, "Connection closed by peer\n"); } return -1; @@ -110,7 +113,7 @@ int main(int argc, char *argv[]) { if(max > sizeof buf) max = sizeof buf; - if((dir & 1) && max) + if((dir & DIR_READ) && max) poll(fds, 2, timeout.tv_sec * 1000 + timeout.tv_usec / 1000); else poll(fds + 1, 1, timeout.tv_sec * 1000 + timeout.tv_usec / 1000); @@ -121,7 +124,7 @@ int main(int argc, char *argv[]) { ssize_t len = read(0, buf, max); if(len <= 0) { fds[0].fd = -1; - dir &= ~1; + dir &= ~DIR_READ; if(c) utcp_shutdown(c, SHUT_WR); if(len == -1) -- 2.39.5