diff options
author | Josh Blum <josh@joshknows.com> | 2010-11-17 09:21:04 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-11-17 09:21:04 -0800 |
commit | d7317dac9360f26444da4043ca066a46749917b3 (patch) | |
tree | ed8de20513100b3fef63d950a60bcc25165d66ff /host/lib | |
parent | 755569e66f7a939aa9392a79bf637d823fb78b84 (diff) | |
download | uhd-d7317dac9360f26444da4043ca066a46749917b3.tar.gz uhd-d7317dac9360f26444da4043ca066a46749917b3.tar.bz2 uhd-d7317dac9360f26444da4043ca066a46749917b3.zip |
udp: added polling alternative to select for mac
Diffstat (limited to 'host/lib')
-rw-r--r-- | host/lib/transport/udp_simple.cpp | 13 |
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)*/ } /*********************************************************************** |