2

Does anybody know why this gives "Invalid argument" error..

boost::asio::ip::tcp::endpoint ep(address::from_string("localhost"), 8000);

but below works fine

boost::asio::ip::tcp::endpoint ep(address::from_string("127.0.0.1"), 8000);

I'm using boost 1.67.0

  • 4
    Because, as the docs say: `Create an address from an IPv4 address string in dotted decimal form, or from an IPv6 address in hexadecimal notation.`. `localhost` is not a `IPv4 address string in dotted decimal form`. – tkausl Nov 08 '18 at 05:47
  • 4
    I see. Should use resolver instead. Thanks. – StudyNPractice Nov 08 '18 at 05:54

0 Answers0