summaryrefslogtreecommitdiffstats
path: root/host/lib/transport
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-02-22 11:42:32 -0800
committerJosh Blum <josh@joshknows.com>2010-02-22 11:42:32 -0800
commitd42e588d76efc41d18dabc75027347fe123904d1 (patch)
tree6a9eccb81538179be69d59677e465e15777202ae /host/lib/transport
parent9c9c96896cb38054e84213aa222883d34c7dd07b (diff)
downloaduhd-d42e588d76efc41d18dabc75027347fe123904d1.tar.gz
uhd-d42e588d76efc41d18dabc75027347fe123904d1.tar.bz2
uhd-d42e588d76efc41d18dabc75027347fe123904d1.zip
Moved the udp implementation guts into the cpp file
Diffstat (limited to 'host/lib/transport')
-rw-r--r--host/lib/transport/udp.cpp45
1 files changed, 40 insertions, 5 deletions
diff --git a/host/lib/transport/udp.cpp b/host/lib/transport/udp.cpp
index 06defb107..af60760a5 100644
--- a/host/lib/transport/udp.cpp
+++ b/host/lib/transport/udp.cpp
@@ -20,7 +20,42 @@
#include <boost/assign/list_of.hpp>
#include <iostream>
-uhd::transport::udp::udp(const std::string &addr, const std::string &port, bool bcast){
+/***********************************************************************
+ * UDP implementation class
+ **********************************************************************/
+class udp_impl : public uhd::transport::udp{
+public:
+ //structors
+ udp_impl(const std::string &addr, const std::string &port, bool bcast);
+ ~udp_impl(void);
+
+ //send/recv
+ void send(const std::vector<boost::asio::const_buffer> &buffs);
+ void send(const boost::asio::const_buffer &buff);
+ uhd::shared_iovec recv(void);
+
+private:
+ boost::asio::ip::udp::socket *_socket;
+ boost::asio::ip::udp::endpoint _receiver_endpoint;
+ boost::asio::ip::udp::endpoint _sender_endpoint;
+ boost::asio::io_service _io_service;
+};
+
+/***********************************************************************
+ * UDP public make function
+ **********************************************************************/
+uhd::transport::udp::sptr uhd::transport::udp::make(
+ const std::string &addr,
+ const std::string &port,
+ bool bcast
+){
+ return uhd::transport::udp::sptr(new udp_impl(addr, port, bcast));
+}
+
+/***********************************************************************
+ * UDP implementation methods
+ **********************************************************************/
+udp_impl::udp_impl(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
@@ -40,20 +75,20 @@ uhd::transport::udp::udp(const std::string &addr, const std::string &port, bool
}
-uhd::transport::udp::~udp(void){
+udp_impl::~udp_impl(void){
delete _socket;
}
-void uhd::transport::udp::send(const std::vector<boost::asio::const_buffer> &buffs){
+void udp_impl::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){
+void udp_impl::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){
+uhd::shared_iovec udp_impl::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