I’m writing a server over TCP using boost::asio. I’m trying to find a way to block connections outside localhost. Only thing I found is this. There is:
boost::asio::ip::host_name()
which returns “tomasz-lenovo-ideapad-Y530” (that’s the name of my machine). How to get raw ip (“127.0.0.1” or “localhost”) from it?
From the socket object that serve given connection.
FYI: If you want to prevent any connections from other machines, its enough to listen 127.0.0.1 and not listen other interfaces. To do this, you should create acceptor like this:
This will listen 127.0.0.1 on port 5555 only