D
D
Daniel Demidko2017-07-02 12:40:43
C++ / C#
Daniel Demidko, 2017-07-02 12:40:43

What's wrong with Boost.Asio?

87d8abe6b98d41f1bfd6973c7d2cd4e2.PNG
Did everything according to John Torjo's book - Boost.Asio C++ Network Programming, what's wrong?
Tried to turn off the firewall, still throws an incomprehensible error.

The code
int main()
{
    using namespace boost::asio;
    io_service service;
    ip::tcp::endpoint endp(ip::address::from_string("127.0.0.1"), 2001);
    ip::tcp::socket sock(service);
    try {
        sock.connect(endp);
    }
    catch (boost::system::system_error error) {
        std::cout << error.what() << std::endl;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Ariox41, 2017-07-02
@DanielDemidko

To display the message in a normal way, try executing the command chcp 1251before starting the program. Or you can change the default encoding in the registry, as done here .
Regarding the error itself: in Windows, by default, ports are divided into two groups, working with which requires different rights (in fact, everything is more complicated there, but I don’t remember the details). Try increasing the port number, something like 51501. Or run it with administrator rights to check. This may not be your problem, but I have experienced this.
EDIT: If it doesn't work with encodings, print the error number and search for it, boost allows you to do this. Well, let me remind you that for the client to work, you must first start the server, otherwise you never know.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question