diff options
author | Josh Blum <josh@joshknows.com> | 2010-07-19 10:57:39 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-07-19 10:57:39 -0700 |
commit | ef9a395414acc203cc02e551e1790277cd0ef1f9 (patch) | |
tree | 1a6cc02ca18cb30bf1f4f253f3550743d7d43ea9 /host/lib/transport | |
parent | 8a7a824848f0a6276c0dc209bbd3ceeeb1eb7bd5 (diff) | |
download | uhd-ef9a395414acc203cc02e551e1790277cd0ef1f9.tar.gz uhd-ef9a395414acc203cc02e551e1790277cd0ef1f9.tar.bz2 uhd-ef9a395414acc203cc02e551e1790277cd0ef1f9.zip |
usrp2: add a timeout to udp control and make it large for usrp2 control transactions
Diffstat (limited to 'host/lib/transport')
-rw-r--r-- | host/lib/transport/udp_simple.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/host/lib/transport/udp_simple.cpp b/host/lib/transport/udp_simple.cpp index f339127ad..89750f99d 100644 --- a/host/lib/transport/udp_simple.cpp +++ b/host/lib/transport/udp_simple.cpp @@ -34,12 +34,13 @@ using namespace uhd::transport; * This is okay bacause this is the slow-path implementation. * * \param socket the asio socket + * \param timeout_ms the timeout in milliseconds */ static void reasonable_recv_timeout( - boost::asio::ip::udp::socket &socket + boost::asio::ip::udp::socket &socket, size_t timeout_ms ){ boost::asio::deadline_timer timer(socket.get_io_service()); - timer.expires_from_now(boost::posix_time::milliseconds(100)); + timer.expires_from_now(boost::posix_time::milliseconds(timeout_ms)); while (not (socket.available() or timer.expires_from_now().is_negative())){ boost::this_thread::sleep(boost::posix_time::milliseconds(1)); } @@ -55,8 +56,8 @@ public: ~udp_connected_impl(void); //send/recv - size_t send(const boost::asio::const_buffer &buff); - size_t recv(const boost::asio::mutable_buffer &buff); + size_t send(const boost::asio::const_buffer &); + size_t recv(const boost::asio::mutable_buffer &, size_t); private: boost::asio::ip::udp::socket *_socket; @@ -85,8 +86,8 @@ size_t udp_connected_impl::send(const boost::asio::const_buffer &buff){ return _socket->send(boost::asio::buffer(buff)); } -size_t udp_connected_impl::recv(const boost::asio::mutable_buffer &buff){ - reasonable_recv_timeout(*_socket); +size_t udp_connected_impl::recv(const boost::asio::mutable_buffer &buff, size_t timeout_ms){ + reasonable_recv_timeout(*_socket, timeout_ms); if (not _socket->available()) return 0; return _socket->receive(boost::asio::buffer(buff)); } @@ -101,8 +102,8 @@ public: ~udp_broadcast_impl(void); //send/recv - size_t send(const boost::asio::const_buffer &buff); - size_t recv(const boost::asio::mutable_buffer &buff); + size_t send(const boost::asio::const_buffer &); + size_t recv(const boost::asio::mutable_buffer &, size_t); private: boost::asio::ip::udp::socket *_socket; @@ -136,8 +137,8 @@ size_t udp_broadcast_impl::send(const boost::asio::const_buffer &buff){ return _socket->send_to(boost::asio::buffer(buff), _receiver_endpoint); } -size_t udp_broadcast_impl::recv(const boost::asio::mutable_buffer &buff){ - reasonable_recv_timeout(*_socket); +size_t udp_broadcast_impl::recv(const boost::asio::mutable_buffer &buff, size_t timeout_ms){ + reasonable_recv_timeout(*_socket, timeout_ms); if (not _socket->available()) return 0; boost::asio::ip::udp::endpoint sender_endpoint; return _socket->receive_from(boost::asio::buffer(buff), sender_endpoint); |