title: C++ udp boost client doesn't receive udp messages
body: <p>When I run:</p>
  <pre><code>nc -ul &lt;ip address&gt; &lt;port&gt;
  </code></pre>
  <p>I receive messages from the udp server. However when I try to reproduce the equivalent using the below C++ program with boost it just freezes on receive_from:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/array.hpp&gt;
  #include &lt;boost/asio.hpp&gt;
  
  using boost::asio::ip::udp;
  
  int main(int argc, char *argv[]) {
      try {
          if (argc != 3) {
              std::cerr &lt;&lt; &quot;Usage: client &lt;host&gt; &lt;port&gt;&quot; &lt;&lt; std::endl;
              return 1;
          }
  
          boost::asio::io_context ioContext;
  
          udp::resolver resolver(ioContext);
          udp::resolver::query query(udp::v4(), argv[1], argv[2]);
          udp::endpoint endpoint = *resolver.resolve(query);
  
          udp::socket socket(ioContext);
          socket.open(udp::v4());
  
  //        boost::array&lt;char, 1&gt; sendBuf = {0};
  //        socket.send_to(boost::asio::buffer(sendBuf), endpoint);
  
          char letter = 0;
          udp::endpoint sender_endpoint;
          while(socket.receive_from(boost::asio::buffer(&amp;letter, 1), endpoint)) {
              std::cout &lt;&lt; letter;
          }
      }
      catch (std::exception &amp;e) {
          std::cerr &lt;&lt; e.what() &lt;&lt; std::endl;
      }
  
      return 0;
  }
  </code></pre>
  <p>Additionally I'm just modeling the above code off of the boost udp client code in their tutorial seen here:</p>
  <pre><code>//
  // client.cpp
  // ~~~~~~~~~~
  //
  // Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
  //
  // Distributed under the Boost Software License, Version 1.0. (See accompanying
  // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  //
  
  #include &lt;iostream&gt;
  #include &lt;boost/array.hpp&gt;
  #include &lt;boost/asio.hpp&gt;
  
  using boost::asio::ip::udp;
  
  int main(int argc, char* argv[])
  {
    try
    {
      if (argc != 2)
      {
        std::cerr &lt;&lt; &quot;Usage: client &lt;host&gt;&quot; &lt;&lt; std::endl;
        return 1;
      }
  
      boost::asio::io_context io_context;
  
      udp::resolver resolver(io_context);
      udp::endpoint receiver_endpoint =
        *resolver.resolve(udp::v4(), argv[1], &quot;daytime&quot;).begin();
  
      udp::socket socket(io_context);
      socket.open(udp::v4());
  
      boost::array&lt;char, 1&gt; send_buf  = {{ 0 }};
      socket.send_to(boost::asio::buffer(send_buf), receiver_endpoint);
  
      boost::array&lt;char, 128&gt; recv_buf;
      udp::endpoint sender_endpoint;
      size_t len = socket.receive_from(
          boost::asio::buffer(recv_buf), sender_endpoint);
  
      std::cout.write(recv_buf.data(), len);
    }
    catch (std::exception&amp; e)
    {
      std::cerr &lt;&lt; e.what() &lt;&lt; std::endl;
    }
  
    return 0;
  }
  </code></pre>
  <p>I have a suspicion that the tutorial code just doesn't work for my case? Not sure what's wrong or what's the difference. What's the right way to make a standard udp echo client?</p>