本文整理汇总了C++中Csock::SetSockName方法的典型用法代码示例。如果您正苦于以下问题:C++ Csock::SetSockName方法的具体用法?C++ Csock::SetSockName怎么用?C++ Csock::SetSockName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Csock
的用法示例。
在下文中一共展示了Csock::SetSockName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadLine
void CIncomingConnection::ReadLine(const CString& sLine) {
bool bIsHTTP = (sLine.WildCmp("GET * HTTP/1.?\r\n") ||
sLine.WildCmp("POST * HTTP/1.?\r\n"));
bool bAcceptHTTP = (m_eAcceptType == CListener::ACCEPT_ALL) ||
(m_eAcceptType == CListener::ACCEPT_HTTP);
bool bAcceptIRC = (m_eAcceptType == CListener::ACCEPT_ALL) ||
(m_eAcceptType == CListener::ACCEPT_IRC);
Csock* pSock = nullptr;
if (!bIsHTTP) {
// Let's assume it's an IRC connection
if (!bAcceptIRC) {
Write("ERROR :We don't take kindly to your types around here!\r\n");
Close(CLT_AFTERWRITE);
DEBUG("Refused IRC connection to non IRC port");
return;
}
pSock = new CClient();
CZNC::Get().GetManager().SwapSockByAddr(pSock, this);
// And don't forget to give it some sane name / timeout
pSock->SetSockName("USR::???");
} else {
// This is a HTTP request, let the webmods handle it
if (!bAcceptHTTP) {
Write(
"HTTP/1.0 403 Access Denied\r\n\r\nWeb Access is not "
"enabled.\r\n");
Close(CLT_AFTERWRITE);
DEBUG("Refused HTTP connection to non HTTP port");
return;
}
pSock = new CWebSock(m_sURIPrefix);
CZNC::Get().GetManager().SwapSockByAddr(pSock, this);
// And don't forget to give it some sane name / timeout
pSock->SetSockName("WebMod::Client");
}
// TODO can we somehow get rid of this?
pSock->ReadLine(sLine);
pSock->PushBuff("", 0, true);
}