Quantcast

udp::endpoint listen_endpoint invalid argument

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

udp::endpoint listen_endpoint invalid argument

Boost - Users mailing list
Hi,

I built doc/html/boost_asio/example/timeouts/blocking_udp_client.cpp on Debian Jessie, but when I run it, I got Invalid argument on the statement of udp::endpoint listen_endpoint( boost::asio::ip::address::from_string(argv[1]), std::atoi(argv[2]));

To simplify it, I changed to:
udp::endpoint listen_endpoint( boost::asio::ip::address::from_string("localhost"), 15555);

Appreciate any clues what's wrong with that statement and why it caused invalid argument?

Thank you.



_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: udp::endpoint listen_endpoint invalid argument

Boost - Users mailing list
On 11/04/2017 17:32, jupiter via Boost-users wrote:

> I built doc/html/boost_asio/example/timeouts/blocking_udp_client.cpp on
> Debian Jessie, but when I run it, I got Invalid argument on the
> statement of udp::endpoint listen_endpoint(
> boost::asio::ip::address::from_string(argv[1]), std::atoi(argv[2]));
>
> To simplify it, I changed to:
> udp::endpoint listen_endpoint(
> boost::asio::ip::address::from_string("localhost"), 15555);
>
> Appreciate any clues what's wrong with that statement and why it caused
> invalid argument?

What command line parameters did you call it with?


_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: udp::endpoint listen_endpoint invalid argument

Boost - Users mailing list
In reply to this post by Boost - Users mailing list
On 04/11/2017 07:32 AM, jupiter via Boost-users wrote:

> To simplify it, I changed to:
> udp::endpoint listen_endpoint(
> boost::asio::ip::address::from_string("localhost"), 15555);

Quoting the documentation:

  "from_string    Create an address from an IPv4 address string in
                  dotted decimal form, or from an IPv6 address in
                  hexadecimal notation."

You need to resolve "localhost" first.

_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: udp::endpoint listen_endpoint invalid argument

Boost - Users mailing list
Thanks Bjorn and Gavin, change localhost to an IPv4 address fixed that problem, so how can we use the domain name rather than the IPv4 dot address?

Cheers.

On Tue, Apr 11, 2017 at 7:21 PM, Bjorn Reese via Boost-users <[hidden email]> wrote:
On 04/11/2017 07:32 AM, jupiter via Boost-users wrote:

To simplify it, I changed to:
udp::endpoint listen_endpoint(
boost::asio::ip::address::from_string("localhost"), 15555);

Quoting the documentation:

 "from_string    Create an address from an IPv4 address string in
                 dotted decimal form, or from an IPv6 address in
                 hexadecimal notation."

You need to resolve "localhost" first.


_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: udp::endpoint listen_endpoint invalid argument

Boost - Users mailing list
On 12/04/2017 12:45, jupiter via Boost-users wrote:
> Thanks Bjorn and Gavin, change localhost to an IPv4 address fixed that
> problem, so how can we use the domain name rather than the IPv4 dot address?

As Bjorn suggested, you need to call resolve or async_resolve on a
tcp::resolver or udp::resolver.  There are other examples that
demonstrate this.


_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Loading...