Question

NetworkInterface::NetworkInterface(void):
    sock(io_service)
{
    // ------------------
    // CONNECT TO SERVER
    // ------------------
    tcp::resolver resolver(io_service);
    string ip = "127.0.0.1";
    tcp::resolver::query query(ip, "daytime");
    tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);

    sock.connect(*endpoint_iterator);
}

I'm trying to make this work but after the connect method gets called I get a runtime exception:

Unhandled exception at at 0x754E2EEC in TestClient.exe: Microsoft C++ exception: boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::system::system_error> > at memory location 0x0072F140.

I have no idea what I'm doing wrong. The thing I'm trying to do is get the sock variable to be used in the whole class (so I've declared it in the header as you may have noticed).

EDIT: As for includes, I included the boost root in the include directories thing. And the boost root/stage/lib path in the library directories. I also added a lib file to the additional dependencies thing. (Properties -> Linker -> Input)

Was it helpful?

Solution

By catching the exception, you should be able to see the actual error message, so you can see what the actual issue is:

NetworkInterface::NetworkInterface(void):
   sock(io_service)
{
    try {
        // your code here..
    } catch (const std::exception& error) {
        // Should print the actual error message
        std::cerr << error.what() << std::endl;
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top