I'm writing a server in C++ using Boost ASIO library. I'd like to get the string representation of client IP to be shown in my server's logs. Does anyone know how to do it?
C++ – How to get IP address of boost::asio::ip::tcp::socket
boostboost-asioc++networking
Related Question
- C++ – Best documentation for Boost:asio
- C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming
- C++ – C++ programmers minimize use of ‘new’
- Python – Why is reading lines from stdin much slower in C++ than Python
- C++ – How does libuv compare to Boost/ASIO
- Asio without Boost
Best Solution
The socket has a function that will retrieve the remote endpoint. I'd give this (long-ish) chain of commands a go, they should retrieve the string representation of the remote end IP address:
or the one-liner version: