Boost ASIO bind: Invalid argument
<p>I am trying to bind an endpoint to a socket and I receive such exception</p>

<pre><code>terminate called after throwing an instance of 'boost::exception_detail::clone_impl&lt;boost::exception_detail::error_info_injector&lt;boost::system::system_error&gt; &gt;'
  what():  bind: Invalid argument
Aborted (core dumped)
</code></pre>

<p>The code is as following. I prefer to solve the problem of binding.</p>

<pre><code>#include &lt;ctime&gt;
#include &lt;iostream&gt;
#include &lt;stdio.h&gt;
#include &lt;string&gt;
#include &lt;boost/array.hpp&gt;
#include &lt;boost/asio.hpp&gt;

using boost::asio::ip::udp;

int main()
{
    const int port=2405;
    const std::string ip="127.0.0.1";

    boost::asio::io_service io_service;
    udp::endpoint endpoint;
    udp::socket socket(io_service, udp::endpoint(udp::v4(), 0));

    udp::resolver resolver(io_service);
    endpoint = *resolver.resolve({udp::v4(), ip, std::to_string(port)});
    socket.bind(endpoint);

    return 0;
}
</code></pre>

<p>make:</p>

<pre><code>g++ test.cpp -Wfatal-errors -o test -std=c++11 -lboost_system -lboost_thread -lboost_serialization -pthread
</code></pre>