summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-11-17 09:21:04 -0800
committerJosh Blum <josh@joshknows.com>2010-11-17 09:21:04 -0800
commitd7317dac9360f26444da4043ca066a46749917b3 (patch)
treeed8de20513100b3fef63d950a60bcc25165d66ff
parent755569e66f7a939aa9392a79bf637d823fb78b84 (diff)
downloaduhd-d7317dac9360f26444da4043ca066a46749917b3.tar.gz
uhd-d7317dac9360f26444da4043ca066a46749917b3.tar.bz2
uhd-d7317dac9360f26444da4043ca066a46749917b3.zip
udp: added polling alternative to select for mac
-rw-r--r--host/lib/transport/udp_simple.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/host/lib/transport/udp_simple.cpp b/host/lib/transport/udp_simple.cpp
index 5829b462b..6799ac7b2 100644
--- a/host/lib/transport/udp_simple.cpp
+++ b/host/lib/transport/udp_simple.cpp
@@ -35,6 +35,8 @@ using namespace uhd::transport;
static bool wait_available(
boost::asio::ip::udp::socket &socket, double timeout
){
+ #if defined(UHD_PLATFORM_LINUX) || defined(UHD_PLATFORM_WIN32)
+
//setup timeval for timeout
timeval tv;
tv.tv_sec = 0;
@@ -46,6 +48,17 @@ static bool wait_available(
FD_SET(socket.native(), &rset);
return ::select(socket.native()+1, &rset, NULL, NULL, &tv) > 0;
+
+ #else /*defined(UHD_PLATFORM_LINUX) || defined(UHD_PLATFORM_WIN32)*/
+
+ //FIXME: why does select fail on macintosh?
+ for (size_t i = 0; i < size_t(timeout*1e3); i++){
+ if (socket.available()) return true;
+ boost::this_thread::sleep(boost::posix_time::milliseconds(1));
+ }
+ return false;
+
+ #endif /*defined(UHD_PLATFORM_LINUX) || defined(UHD_PLATFORM_WIN32)*/
}
/***********************************************************************