diff options
author | Josh Blum <josh@joshknows.com> | 2010-02-11 20:24:01 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2010-02-11 20:24:01 -0800 |
commit | 350f5c5decca20a54132867283448fd32226bbc2 (patch) | |
tree | 261ec83435d3625ea307e21813ea814113278b79 /lib/transport | |
parent | 6c7d9f1f7573fc73522499573560bf1aef64f414 (diff) | |
download | uhd-350f5c5decca20a54132867283448fd32226bbc2.tar.gz uhd-350f5c5decca20a54132867283448fd32226bbc2.tar.bz2 uhd-350f5c5decca20a54132867283448fd32226bbc2.zip |
Getting hello packets from the usrp2 with ip and mac addrs.
Cleaned up the mb build system a bit.
Diffstat (limited to 'lib/transport')
-rw-r--r-- | lib/transport/udp.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/transport/udp.cpp b/lib/transport/udp.cpp index 5b221551b..f42ddcb75 100644 --- a/lib/transport/udp.cpp +++ b/lib/transport/udp.cpp @@ -17,6 +17,7 @@ #include <uhd/transport/udp.hpp> #include <boost/format.hpp> +#include <boost/assign/list_of.hpp> #include <iostream> uhd::transport::udp::udp(const std::string &addr, const std::string &port, bool bcast){ @@ -47,19 +48,20 @@ void uhd::transport::udp::send(const std::vector<boost::asio::const_buffer> &buf _socket->send_to(buffs, _receiver_endpoint); } -void uhd::transport::udp::send(const void *buff, size_t len){ - _socket->send_to(boost::asio::buffer(buff, len), _receiver_endpoint); +void uhd::transport::udp::send(const boost::asio::const_buffer &buff){ + std::vector<boost::asio::const_buffer> buffs = boost::assign::list_of(buff); + send(buffs); } -const boost::asio::const_buffer uhd::transport::udp::recv(void){ +boost::asio::const_buffer uhd::transport::udp::recv(void){ + size_t len = 0; //recv if data is available if (_socket->available()){ - size_t len = _socket->receive_from( + len = _socket->receive_from( boost::asio::buffer(_recv_buff, sizeof(_recv_buff)), _sender_endpoint ); - return boost::asio::buffer(_recv_buff, len); } - //return an empty buffer - return boost::asio::buffer(_recv_buff, 0); + //return the buffer with the received length + return boost::asio::buffer(_recv_buff, len); } |