Browse Source

[trac499] Return data back to the client in udpSendReceive test

In a previous change, nothing was being returned to the client in
the UDOP send/receive test.  This was only detected on the Mac.
This change fixes that problem.
Stephen Morris 14 years ago
parent
commit
ba92da6356
1 changed files with 9 additions and 0 deletions
  1. 9 0
      src/lib/asiolink/tests/io_fetch_unittest.cc

+ 9 - 0
src/lib/asiolink/tests/io_fetch_unittest.cc

@@ -166,6 +166,10 @@ public:
         // Return a message back to the IOFetch object.
         // Return a message back to the IOFetch object.
         socket->send_to(asio::buffer(return_data_.c_str(), return_data_.size()),
         socket->send_to(asio::buffer(return_data_.c_str(), return_data_.size()),
                                      *remote);
                                      *remote);
+        if (debug_) {
+            cout << "udpReceiveHandler(): returned " << return_data_.size() <<
+                    " bytes to the client" << endl;
+        }
     }
     }
 
 
     /// \brief Completion Handler for accepting TCP data
     /// \brief Completion Handler for accepting TCP data
@@ -510,6 +514,7 @@ TEST_F(IOFetchTest, UdpSendReceive) {
     udp::socket socket(service_.get_io_service(), udp::v4());
     udp::socket socket(service_.get_io_service(), udp::v4());
     socket.set_option(socket_base::reuse_address(true));
     socket.set_option(socket_base::reuse_address(true));
     socket.bind(udp::endpoint(TEST_HOST, TEST_PORT));
     socket.bind(udp::endpoint(TEST_HOST, TEST_PORT));
+    return_data_ = "Message returned to the client";
 
 
     udp::endpoint remote;
     udp::endpoint remote;
     socket.async_receive_from(asio::buffer(receive_buffer_, sizeof(receive_buffer_)),
     socket.async_receive_from(asio::buffer(receive_buffer_, sizeof(receive_buffer_)),
@@ -517,6 +522,10 @@ TEST_F(IOFetchTest, UdpSendReceive) {
         boost::bind(&IOFetchTest::udpReceiveHandler, this, &remote, &socket,
         boost::bind(&IOFetchTest::udpReceiveHandler, this, &remote, &socket,
                     _1, _2));
                     _1, _2));
     service_.get_io_service().post(udp_fetch_);
     service_.get_io_service().post(udp_fetch_);
+    if (debug_) {
+        cout << "udpSendReceive: async_receive_from posted, waiting for callback" <<
+                endl;
+    }
     service_.run();
     service_.run();
 
 
     socket.close();
     socket.close();