本文整理汇总了C++中boost::asio::ip::tcp::socket::remote_endpoint方法的典型用法代码示例。如果您正苦于以下问题:C++ socket::remote_endpoint方法的具体用法?C++ socket::remote_endpoint怎么用?C++ socket::remote_endpoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::asio::ip::tcp::socket
的用法示例。
在下文中一共展示了socket::remote_endpoint方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle_request
void server::handle_request(boost::asio::ip::tcp::socket& socket,
const request& req, reply& rep)
{
using namespace boost::posix_time;
detail::s_log.reset(new ostringstream);
ptime start = second_clock::local_time();
try
{
handle_request(req, rep);
}
catch (...)
{
rep = reply::stock_reply(internal_server_error);
}
// protect the output stream from garbled log messages
boost::mutex::scoped_lock lock(detail::s_log_lock);
cout << socket.remote_endpoint().address()
<< " [" << start << "] "
<< second_clock::local_time() - start << ' '
<< rep.status << ' '
<< detail::s_log->str() << endl;
}
示例2: GetRemoteAddressAndPort
bool TcpProxyServer::GetRemoteAddressAndPort(boost::asio::ip::tcp::socket& clientSocket, boost::asio::ip::address& remoteAddress, unsigned short& remotePort)
{
boost::asio::ip::tcp::socket::endpoint_type userAgentEnpoint = clientSocket.remote_endpoint();
unsigned short userAgentPort = userAgentEnpoint.port();
boost::asio::ip::address userAgentIP = userAgentEnpoint.address();
if(userAgentIP != boost::asio::ip::address_v4::from_string("127.0.0.1")) {
return false;
}
std::pair<u_long, USHORT> remoteAddressPair = WinsockHooker::GetRemoteAddressPair(userAgentPort);
if(remoteAddressPair.first == 0ul) {
return false;
}
boost::asio::ip::address_v4 remote_address(remoteAddressPair.first);
unsigned short remote_port = remoteAddressPair.second;
if(remote_address == boost::asio::ip::address_v4::from_string("127.0.0.1") && remote_port == listen_port)
{
return false;
}
remoteAddress = remote_address;
remotePort = remote_port;
TSINFO4CXX("Connect: IP:" << remoteAddress.to_string() << ", Port: " << remotePort);
return true;
}
示例3: on_connect
void on_connect(boost::asio::ip::tcp::socket &socket) {
SNOW_LOG_TRACE("new Connection socket fd {}, local addr {}, peer addr {}",
socket.native(),
socket.local_endpoint(),
socket.remote_endpoint());
std::make_shared<Connection>(socket, m_request_dispatcher, m_pkg_spliter, 100 * 1000)->start();
}
示例4: Error
/** Check that local endpoint is loopback
*
* @throws Face::Error if validation failed
*/
static void
validateSocket(boost::asio::ip::tcp::socket& socket)
{
if (!socket.local_endpoint().address().is_loopback() ||
!socket.remote_endpoint().address().is_loopback())
{
throw Face::Error("TcpLocalFace can be created only on loopback interface");
}
}
示例5: handle_write
void handler::handle_write() {
dnet_log(m_monitor.node(), DNET_LOG_DEBUG, "monitor: server: send requested statistics: finished: %s:%d", m_remote.c_str(), m_socket.remote_endpoint().port());
close();
}
示例6: async_write
void handler::async_write(std::string data) {
auto self(shared_from_this());
m_report = std::move(data);
dnet_log(m_monitor.node(), DNET_LOG_DEBUG, "monitor: server: send requested statistics: started: %s:%d, size: %lu", m_remote.c_str(), m_socket.remote_endpoint().port(), m_report.size());
boost::asio::async_write(m_socket, boost::asio::buffer(m_report),
std::bind(&handler::handle_write, self));
}
示例7: handle_read
void handler::handle_read(const boost::system::error_code &err, size_t size) {
if (err) {
close();
return;
}
auto req = parse_request(size);
std::string content = "";
if (req > 0) {
dnet_log(m_monitor.node(), DNET_LOG_DEBUG, "monitor: server: got statistics request for categories: %lx from: %s:%d", req, m_remote.c_str(), m_socket.remote_endpoint().port());
content = m_monitor.get_statistics().report(req);
}
std::string reply = make_reply(req, content);
async_write(reply);
}
示例8: hash
size_t hash() const override {
std::ostringstream stream;
stream << socket_.remote_endpoint();
return std::hash<std::string>()(stream.str());
}