本文整理汇总了C++中network::EndPoint::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ EndPoint::c_str方法的具体用法?C++ EndPoint::c_str怎么用?C++ EndPoint::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network::EndPoint
的用法示例。
在下文中一共展示了EndPoint::c_str方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: endpoint
//-------------------------------------------------------------------------------------
int TelnetServer::handleInputNotification(int fd)
{
KBE_ASSERT(listener_ == fd);
int tickcount = 0;
while(tickcount ++ < 1024)
{
Network::EndPoint* pNewEndPoint = listener_.accept();
if(pNewEndPoint == NULL){
if(tickcount == 1)
{
WARNING_MSG(fmt::format("TelnetServer::handleInputNotification: accept endpoint({}) {}!\n",
fd, kbe_strerror()));
}
break;
}
else
{
TelnetHandler* pTelnetHandler = new TelnetHandler(pNewEndPoint, this, pNetworkInterface_, passwd_.size() > 0 ?
TelnetHandler::TELNET_STATE_PASSWD : (TelnetHandler::TELNET_STATE)this->deflayer());
if(!pDispatcher_->registerReadFileDescriptor((*pNewEndPoint), pTelnetHandler))
{
ERROR_MSG(fmt::format("TelnetServer::start:: registerReadFileDescriptor(pTelnetHandler) is failed! addr={}\n",
pNewEndPoint->c_str()));
delete pTelnetHandler;
continue;
}
INFO_MSG(fmt::format("TelnetServer::handleInputNotification: new handler({})!\n",
pNewEndPoint->c_str()));
handlers_[(*pNewEndPoint)].reset(pTelnetHandler);
std::string s;
if(passwd_.size() > 0)
{
s = "password:";
}
else
{
s = pTelnetHandler->getWelcome();
}
pNewEndPoint->send(s.c_str(), (int)s.size());
}
}
return 0;
}
示例2: handleInputNotification
//-------------------------------------------------------------------------------------
int HTTPCBHandler::handleInputNotification(int fd)
{
if(fd == *pEndPoint_)
{
u_int16_t port;
u_int32_t addr;
Network::EndPoint* newclient = pEndPoint_->accept(&port, &addr);
if(newclient == NULL)
{
ERROR_MSG(fmt::format("HTTPCBHandler::handleInputNotification: accept is error:{}.\n", kbe_strerror()));
return 0;
}
INFO_MSG(fmt::format("HTTPCBHandler:handleInputNotification: newclient = {}\n",
newclient->c_str()));
newclient->setnonblocking(true);
CLIENT& client = clients_[*newclient];
client.endpoint = KBEShared_ptr< Network::EndPoint >(newclient);
client.state = 0;
Loginapp::getSingleton().networkInterface().dispatcher().registerReadFileDescriptor(*newclient, this);
}
else
{
std::map< int, CLIENT >::iterator iter = clients_.find(fd);
if(iter == clients_.end())
{
ERROR_MSG(fmt::format("HTTPCBHandler:handleInputNotification: fd({}) not found!\n",
fd));
return 0;
}
CLIENT& client = iter->second;
Network::EndPoint* newclient = iter->second.endpoint.get();
char buffer[1024];
int len = newclient->recv(&buffer, 1024);
if(len <= 0)
{
ERROR_MSG(fmt::format("HTTPCBHandler:handleInputNotification: recv error, newclient = {}, recv={}.\n",
newclient->c_str(), len));
if(len == 0)
{
Loginapp::getSingleton().networkInterface().dispatcher().deregisterReadFileDescriptor(*newclient);
clients_.erase(iter);
}
return 0;
}
if(client.state == 1)
{
Loginapp::getSingleton().networkInterface().dispatcher().deregisterReadFileDescriptor(*newclient);
clients_.erase(iter);
}
int type = 0;
std::string s = buffer;
std::string keys = "<policy-file-request/>";
std::string::size_type fi0 = s.find(keys);
if(fi0 != std::string::npos)
{
if(client.state != 1)
{
std::string response = "<?xml version='1.0'?><cross-domain-policy><allow-access-from domain=""*"" to-ports=""*"" /></cross-domain-policy>";
iter->second.endpoint->send(response.c_str(), response.size());
Loginapp::getSingleton().networkInterface().dispatcher().deregisterReadFileDescriptor(*newclient);
clients_.erase(iter);
}
return 0;
}
keys = "accountactivate_";
std::string::size_type fi1 = s.find(keys);
if(fi1 == std::string::npos)
{
keys = "resetpassword_";
fi1 = s.find(keys);
if(fi1 == std::string::npos)
{
keys = "bindmail_";
fi1 = s.find(keys);
if(fi1 != std::string::npos)
{
type = 3;
}
}
else
{
type = 2;
}
}
else
{
//.........这里部分代码省略.........