Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 942697
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:18:58+00:00 2026-05-15T22:18:58+00:00

I am learning boost/asio and writing example program which was in e-book. of course

  • 0

I am learning boost/asio and writing example program which was in e-book.
of course it didn’t work 😉

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

int main () {
   boost::asio::io_service io_service;
   boost::asio::ip::tcp::resolver::query query("www.boost.org", "http");
   boost::asio::ip::tcp::resolver::iterator destination = boost::asio::ip::tcp::resolver::resolve(query); // if i have "." before "resolve" as in books example compilers says i need primary-expresion. 
   boost::asio::ip::tcp::endpoint endpoint;

   while ( destination != end ) {
      endpoint = *destination++;
      std::cout<<endpoint<<std::endl;
   }

   boost::asio::ip::tcp::socket socket(io_service);
   socket.connect(endpoint);
   return 0;
}

compiler output with “::” before “resolve”:

/home/martins/C++/boost_asio_client/client.cpp|7|error: cannot call member function 
‘boost::asio::ip::basic_resolver<InternetProtocol, ResolverService>::iterator 
boost::asio::ip::basic_resolver<InternetProtocol, 
ResolverService>::resolve(boost::asio::ip::basic_resolver<InternetProtocol,
 ResolverService>::query&) 
[with InternetProtocol = boost::asio::ip::tcp, ResolverService = 
boost::asio::ip::resolver_service<boost::asio::ip::tcp>, 
boost::asio::ip::basic_resolver<InternetProtocol, ResolverService>::iterator = 
boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>, 
boost::asio::ip::basic_resolver<InternetProtocol, ResolverService>::query = 
boost::asio::ip::basic_resolver_query<boost::asio::ip::tcp>]’ without object|

How do I resolve address correctly?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:18:59+00:00Added an answer on May 15, 2026 at 10:18 pm

    you need a resolver object. Also your iterator comparison was incorrect, you need to compare against the sentinel value ip::tcp::resolver::iterator().

    #include <boost/asio.hpp>
    #include <iostream>
    
    int main () {
       boost::asio::io_service io_service;
       boost::asio::ip::tcp::resolver::query query("www.boost.org", "http");
       boost::asio::ip::tcp::resolver resolver( io_service );
       boost::asio::ip::tcp::resolver::iterator destination = resolver.resolve(query);
       boost::asio::ip::tcp::endpoint endpoint;
    
       while ( destination != boost::asio::ip::tcp::resolver::iterator() ) {
         endpoint = *destination++;
         std::cout<<endpoint<<std::endl;
       }
    
       boost::asio::ip::tcp::socket socket(io_service);
       socket.connect(endpoint);
       return 0;
    }
    

    here is a sample compile and run of your code.

    samm@macmini ~> g++ -lboost_system resolve.cc
    samm@macmini ~> ./a.out 
    129.79.245.252:80
    samm@macmini ~> echo $?
    0
    samm@macmini ~>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.