diff options
author | root <root@usrp1-e.(none)> | 2010-03-23 13:35:36 +0000 |
---|---|---|
committer | root <root@usrp1-e.(none)> | 2010-03-23 13:35:36 +0000 |
commit | c329da8f953c3981e23791c688f350b27541554a (patch) | |
tree | 3447dd657bf7221e3b4b1a9147ce1bd2ffa430b9 /host/lib/transport/udp.cpp | |
parent | f6ec1e45117f5794facd1cd8e11cbfacabdeb166 (diff) | |
parent | 09a21dd6d4bc5b7f032e07cfabcba9f55d25b0f6 (diff) | |
download | uhd-c329da8f953c3981e23791c688f350b27541554a.tar.gz uhd-c329da8f953c3981e23791c688f350b27541554a.tar.bz2 uhd-c329da8f953c3981e23791c688f350b27541554a.zip |
Merge branch 'u1e_uhd' of git@ettus.sourcerepo.com:ettus/uhd into u1e_uhd
Diffstat (limited to 'host/lib/transport/udp.cpp')
-rw-r--r-- | host/lib/transport/udp.cpp | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/host/lib/transport/udp.cpp b/host/lib/transport/udp.cpp deleted file mode 100644 index 06defb107..000000000 --- a/host/lib/transport/udp.cpp +++ /dev/null @@ -1,67 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see <http://www.gnu.org/licenses/>. -// - -#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){ - //std::cout << boost::format("Creating udp transport for %s %s") % addr % port << std::endl; - - // resolve the address - boost::asio::ip::udp::resolver resolver(_io_service); - boost::asio::ip::udp::resolver::query query(boost::asio::ip::udp::v4(), addr, port); - _receiver_endpoint = *resolver.resolve(query); - - // Create and open the socket - _socket = new boost::asio::ip::udp::socket(_io_service); - _socket->open(boost::asio::ip::udp::v4()); - - if (bcast){ - // Allow broadcasting - boost::asio::socket_base::broadcast option(true); - _socket->set_option(option); - } - -} - -uhd::transport::udp::~udp(void){ - delete _socket; -} - -void uhd::transport::udp::send(const std::vector<boost::asio::const_buffer> &buffs){ - _socket->send_to(buffs, _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); -} - -uhd::shared_iovec uhd::transport::udp::recv(void){ - //allocate a buffer for the number of bytes available (could be zero) - uhd::shared_iovec iov(_socket->available()); - //call recv only if data is available - if (iov.len != 0){ - _socket->receive_from( - boost::asio::buffer(iov.base, iov.len), - _sender_endpoint - ); - } - return iov; -} |