Darren Cook | 10 Feb 10:47

ip::address::from_string() not working

ip::address's from_string() function does not seem to be working; it
gives me 0.0.0.0 whatever string I pass.

A very minimal reproducible example below, it outputs:
  Set host to 0.0.0.0

I'm using boost 1.40 (ubuntu 10.04). Google is strangely quiet; so I
guess I'm doing something wrong??

Darren

//Compile and run with "g++ test.cpp -lboost_system;./a.out"

#include <iostream>
#include <boost/asio.hpp>

int main(int argc, char* argv[])
{
    boost::asio::ip::address host;
    host.from_string("127.0.0.1");
    std::cout<<"Set host to "<<host<<"\n";
    return 0;
}

--

-- 
Darren Cook, Software Researcher/Developer

http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)

(Continue reading)

niXman | 10 Feb 11:22
Picon
Gravatar

Re: ip::address::from_string() not working

'boost::asio::ip::address::from_string()' is a static member function:
http://www.boost.org/doc/libs/1_48_0/doc/html/boost_asio/reference/ip__address/from_string.html

usage:
#include <iostream>
#include <boost/asio.hpp>

int main(int argc, char* argv[])
{
   boost::asio::ip::address host =
boost::asio::ip::address::from_string("127.0.0.1");
   std::cout<<"Set host to "<<host<<"\n";
   return 0;
}

http://liveworkspace.org/code/eda650ea2820edf01b09cb2594856ef5

Regards.
niXman.

2012/2/10 Darren Cook <darren <at> dcook.org>:
> ip::address's from_string() function does not seem to be working; it
> gives me 0.0.0.0 whatever string I pass.
>
> A very minimal reproducible example below, it outputs:
>  Set host to 0.0.0.0
>
> I'm using boost 1.40 (ubuntu 10.04). Google is strangely quiet; so I
> guess I'm doing something wrong??
>
(Continue reading)

Darren Cook | 13 Feb 06:17

Re: ip::address::from_string() not working

> ...
>    boost::asio::ip::address host =
> boost::asio::ip::address::from_string("127.0.0.1");

Thanks niXman, that worked! (I had tried using it statically, after
finding an example on the web somewhere, but I got a segmentation error;
it must have been an unlucky coincidence.)

Darren

-- 
Darren Cook, Software Researcher/Developer

http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
asio-users mailing list
asio-users@...
https://lists.sourceforge.net/lists/listinfo/asio-users
_______________________________________________
Using Asio? List your project at
http://think-async.com/Asio/WhoIsUsingAsio

(Continue reading)


Gmane