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

  • Home
  • SEARCH
  • 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 8568407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:06:24+00:00 2026-06-11T18:06:24+00:00

I am making a program for school in which two programs communicate with each

  • 0

I am making a program for school in which two programs communicate with each other.
So far I have not been able to connect the two programs.
Whenever I try to connect to localhost:8888 or 127.0.0.1:8888, the error “Host not found (authoritative)” occurs.

So far my code is this:

Connection.cpp

Connection::Connection(std::string Arg) {
    try
    {
        tcp::resolver resolver(io_service);
        cout<<Arg<<endl;
        tcp::resolver::query query(Arg, "daytime");
        tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
        tcp::resolver::iterator end;

        tcp::socket socket(io_service);
        socket_p = &socket;
        boost::system::error_code error = boost::asio::error::host_not_found;
        while (error && endpoint_iterator != end)
        {
           socket.close();
           socket.connect(*endpoint_iterator++, error);
        }
        if (error)
           throw boost::system::system_error(error);
    }
    catch (std::exception& e)
    {
        std::cerr << e.what() << std::endl;
    }
}
void Connection::Receiver() {
    try{
        for (;;)
        {
            boost::array<char, 128> buf;
            boost::system::error_code error;

            size_t len = socket_p->read_some(boost::asio::buffer(buf), error);

            if (error == boost::asio::error::eof)
                break; // Connection closed cleanly by peer.
            else if (error)
                throw boost::system::system_error(error); // Some other error.

            std::cout.write(buf.data(), len);
        }
    }
    catch (std::exception& e)
    {
        std::cerr << e.what() << std::endl;
    }
} 

In case this helps, I use fedora.

EDIT:
the full code can be found here:
http://www.boost.org/doc/libs/1_36_0/doc/html/boost_asio/tutorial/tutdaytime1.html
i tried to make it OOP (not sure if i did a good job)

  • 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-06-11T18:06:25+00:00Added an answer on June 11, 2026 at 6:06 pm

    You should use:

    tcp::resolver::query query(host, PORT, boost::asio::ip::resolver_query_base::numeric_service);
    

    The problem was that the constructor for query has the
    address_configured flag set by default which won’t return an address
    if the loopback device is the only device with an address. By just
    settings flags to 0 or anything other than address_configured the
    problem is fixed.

    How does Boost Asio's hostname resolution work on Linux? Is it possible to use NSS?

    I will more help you if you paste the whole code. For the very beginning there is really useful piece of code here:

    http://boost.2283326.n4.nabble.com/Simple-telnet-client-demonstration-with-boost-asio-asynchronous-I-O-td2583017.html

    it works and you can test it with your local telnet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a program which controls other processes (as far as stopped and started
I have been making a program that creates multiple CSV's from another source CSV
I've been making a program that uses core data. It has two entities, Medicine
I have been learning C++ in school to create small command-line programs. However, I
I'm making a program which the user build directories (not in windows, in my
I'm making a program which sends invoices to registered users as PDF attachment. Each
Im making a program for class that manages a Hotel. I have a function
I am making a program with which to save banking information (i.e., account, password,
I am currently making a program which is supposed to prompt the user to
I'm making a program in Java which will automatically move all of the .png

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.