summaryrefslogtreecommitdiffstats
path: root/host/lib/transport
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-12-20 14:37:05 -0800
committerJosh Blum <josh@joshknows.com>2011-12-20 14:37:05 -0800
commit1fef438d8ba54d07760a21e8e8b50c05b7ddc051 (patch)
tree2c3fb21379620a196ce6d116418906e95a3fa4de /host/lib/transport
parentcdf8de0ca34d787ee9b3fed543f5e45bc2df00fa (diff)
downloaduhd-1fef438d8ba54d07760a21e8e8b50c05b7ddc051.tar.gz
uhd-1fef438d8ba54d07760a21e8e8b50c05b7ddc051.tar.bz2
uhd-1fef438d8ba54d07760a21e8e8b50c05b7ddc051.zip
usrp2: use the socket to determine the device addr
Diffstat (limited to 'host/lib/transport')
-rw-r--r--host/lib/transport/udp_simple.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/host/lib/transport/udp_simple.cpp b/host/lib/transport/udp_simple.cpp
index bc1bdaf2f..d6c55eae7 100644
--- a/host/lib/transport/udp_simple.cpp
+++ b/host/lib/transport/udp_simple.cpp
@@ -36,7 +36,7 @@ public:
//resolve the address
asio::ip::udp::resolver resolver(_io_service);
asio::ip::udp::resolver::query query(asio::ip::udp::v4(), addr, port);
- _receiver_endpoint = *resolver.resolve(query);
+ _send_endpoint = *resolver.resolve(query);
//create and open the socket
_socket = socket_sptr(new asio::ip::udp::socket(_io_service));
@@ -46,25 +46,30 @@ public:
_socket->set_option(asio::socket_base::broadcast(bcast));
//connect the socket
- if (connect) _socket->connect(_receiver_endpoint);
+ if (connect) _socket->connect(_send_endpoint);
}
size_t send(const asio::const_buffer &buff){
if (_connected) return _socket->send(asio::buffer(buff));
- return _socket->send_to(asio::buffer(buff), _receiver_endpoint);
+ return _socket->send_to(asio::buffer(buff), _send_endpoint);
}
size_t recv(const asio::mutable_buffer &buff, double timeout){
if (not wait_for_recv_ready(_socket->native(), timeout)) return 0;
- return _socket->receive(asio::buffer(buff));
+ return _socket->receive_from(asio::buffer(buff), _recv_endpoint);
+ }
+
+ std::string get_recv_addr(void){
+ return _recv_endpoint.address().to_string();
}
private:
bool _connected;
asio::io_service _io_service;
socket_sptr _socket;
- asio::ip::udp::endpoint _receiver_endpoint;
+ asio::ip::udp::endpoint _send_endpoint;
+ asio::ip::udp::endpoint _recv_endpoint;
};
/***********************************************************************