<tfoot id='qJFBt'></tfoot>
    <bdo id='qJFBt'></bdo><ul id='qJFBt'></ul>

  • <legend id='qJFBt'><style id='qJFBt'><dir id='qJFBt'><q id='qJFBt'></q></dir></style></legend>

    1. <small id='qJFBt'></small><noframes id='qJFBt'>

    2. <i id='qJFBt'><tr id='qJFBt'><dt id='qJFBt'><q id='qJFBt'><span id='qJFBt'><b id='qJFBt'><form id='qJFBt'><ins id='qJFBt'></ins><ul id='qJFBt'></ul><sub id='qJFBt'></sub></form><legend id='qJFBt'></legend><bdo id='qJFBt'><pre id='qJFBt'><center id='qJFBt'></center></pre></bdo></b><th id='qJFBt'></th></span></q></dt></tr></i><div id='qJFBt'><tfoot id='qJFBt'></tfoot><dl id='qJFBt'><fieldset id='qJFBt'></fieldset></dl></div>

        如何获取 boost::asio::ip::tcp::socket 的 IP 地址?

        时间:2023-09-17
          <bdo id='wyp60'></bdo><ul id='wyp60'></ul>

          <small id='wyp60'></small><noframes id='wyp60'>

          1. <legend id='wyp60'><style id='wyp60'><dir id='wyp60'><q id='wyp60'></q></dir></style></legend>

                <tfoot id='wyp60'></tfoot>
                • <i id='wyp60'><tr id='wyp60'><dt id='wyp60'><q id='wyp60'><span id='wyp60'><b id='wyp60'><form id='wyp60'><ins id='wyp60'></ins><ul id='wyp60'></ul><sub id='wyp60'></sub></form><legend id='wyp60'></legend><bdo id='wyp60'><pre id='wyp60'><center id='wyp60'></center></pre></bdo></b><th id='wyp60'></th></span></q></dt></tr></i><div id='wyp60'><tfoot id='wyp60'></tfoot><dl id='wyp60'><fieldset id='wyp60'></fieldset></dl></div>
                    <tbody id='wyp60'></tbody>
                  本文介绍了如何获取 boost::asio::ip::tcp::socket 的 IP 地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在使用 Boost ASIO 库用 C++ 编写服务器.我想在我的服务器日志中显示客户端 IP 的字符串表示.有人知道怎么做吗?

                  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?

                  推荐答案

                  socket 有一个函数可以检索远程端点.我会尝试一下这个(长的)命令链,它们应该检索远程端 IP 地址的字符串表示:

                  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:

                  asio::ip::tcp::socket socket(io_service);
                  // Do all your accepting and other stuff here.
                  
                  asio::ip::tcp::endpoint remote_ep = socket.remote_endpoint();
                  asio::ip::address remote_ad = remote_ep.address();
                  std::string s = remote_ad.to_string();
                  

                  或单线版本:

                  asio::ip::tcp::socket socket(io_service);
                  // Do all your accepting and other stuff here.
                  
                  std::string s = socket.remote_endpoint().address().to_string();
                  

                  这篇关于如何获取 boost::asio::ip::tcp::socket 的 IP 地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:字节序何时成为一个因素? 下一篇:以编程方式获取缓存行大小?

                  相关文章

                  最新文章

                  <tfoot id='unCDq'></tfoot>

                  1. <i id='unCDq'><tr id='unCDq'><dt id='unCDq'><q id='unCDq'><span id='unCDq'><b id='unCDq'><form id='unCDq'><ins id='unCDq'></ins><ul id='unCDq'></ul><sub id='unCDq'></sub></form><legend id='unCDq'></legend><bdo id='unCDq'><pre id='unCDq'><center id='unCDq'></center></pre></bdo></b><th id='unCDq'></th></span></q></dt></tr></i><div id='unCDq'><tfoot id='unCDq'></tfoot><dl id='unCDq'><fieldset id='unCDq'></fieldset></dl></div>

                    <small id='unCDq'></small><noframes id='unCDq'>

                      • <bdo id='unCDq'></bdo><ul id='unCDq'></ul>
                      <legend id='unCDq'><style id='unCDq'><dir id='unCDq'><q id='unCDq'></q></dir></style></legend>