when using remote_endpoint().address() of asio, make failed( undefined reference to `if_indextoname(unsigned int, char*)

jjmin.liang
Posts: 10
Joined: Sat Feb 16, 2019 1:24 pm

when using remote_endpoint().address() of asio, make failed( undefined reference to `if_indextoname(unsigned int, char*)

Postby jjmin.liang » Thu Feb 21, 2019 6:27 am

Hi guys,

I'm writing a tcp server in the ESP32, everything work fine, but when I add the following code to my program, it will make failed, and tell me
undefined reference to `if_indextoname(unsigned int, char*)
.
this is the code will cause the link error:

Code: Select all

this->acceptor->async_accept([this](std::error_code ec, tcp::socket socket) {
        if (!ec) {
            socket.remote_endpoint().address().to_string().c_str(); // this code will cause link error
            ......
        }
        ......
 }
any tips? Thank you!

jjmin.liang
Posts: 10
Joined: Sat Feb 16, 2019 1:24 pm

Re: when using remote_endpoint().address() of asio, make failed( undefined reference to `if_indextoname(unsigned int, ch

Postby jjmin.liang » Sat Feb 23, 2019 8:26 am

I finally solved it. just use raw socket func: getpeername. done!

Who is online

Users browsing this forum: Majestic-12 [Bot] and 128 guests