From 96ee6f96301671688f74cebc2af26ca3864deda9 Mon Sep 17 00:00:00 2001 From: Erik Ekman Date: Thu, 11 Jun 2009 16:53:56 +0000 Subject: [PATCH] Use recv on windows and read for the others --- src/tun.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/tun.c b/src/tun.c index 4f40dd4..0256fdc 100644 --- a/src/tun.c +++ b/src/tun.c @@ -361,7 +361,13 @@ read_tun(int tun_fd, char *buf, size_t len) /* FreeBSD/Darwin/NetBSD has no header */ int bytes; memset(buf, 0, 4); +#ifdef WINDOWS32 + /* Windows needs recv() since it is local UDP socket */ + bytes = recv(tun_fd, buf + 4, len - 4, 0); +#else + /* The other need read() because fd is not a socket */ bytes = read(tun_fd, buf + 4, len - 4); +#endif /*WINDOWS32*/ if (bytes < 0) { return bytes; } else {