diff options
author | Josh Blum <josh@joshknows.com> | 2011-12-21 13:05:44 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-12-21 13:05:44 -0800 |
commit | 9f0a1e3148251c820a73c8a33da92e54aaffee6d (patch) | |
tree | d74b28fdd92a9969c4d71e0cbd5c1425e1ea4dc7 /host/lib/transport | |
parent | 81289ab0510c847daacf75e261cad2de5cd7d508 (diff) | |
parent | bdb267b9f445e929f765b481c038edbd6310ce85 (diff) | |
download | uhd-9f0a1e3148251c820a73c8a33da92e54aaffee6d.tar.gz uhd-9f0a1e3148251c820a73c8a33da92e54aaffee6d.tar.bz2 uhd-9f0a1e3148251c820a73c8a33da92e54aaffee6d.zip |
Merge branch 'network_foo'
Diffstat (limited to 'host/lib/transport')
-rw-r--r-- | host/lib/transport/udp_simple.cpp | 15 |
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; }; /*********************************************************************** |