IP:
std::string sClientIp = socket().remote_endpoint().address().to_string();
port:
unsigned short uiClientPort = socket().remote_endpoint().port();
std::string sClientIp = socket().remote_endpoint().address().to_string();
port:
unsigned short uiClientPort = socket().remote_endpoint().port();

本文介绍了如何使用C++标准库中的方法来获取客户端的IP地址及端口号。通过socket远程端点的方法可以轻松实现这一功能。
191

被折叠的 条评论
为什么被折叠?



