当前位置: 首页>>代码示例>>C++>>正文


C++ GetSockName函数代码示例

本文整理汇总了C++中GetSockName函数的典型用法代码示例。如果您正苦于以下问题:C++ GetSockName函数的具体用法?C++ GetSockName怎么用?C++ GetSockName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetSockName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetX509

void CZNCSock::SSLHandShakeFinished() {
	if (GetType() != ETConn::OUTBOUND) {
		return;
	}

	X509* pCert = GetX509();
	if (!pCert) {
		DEBUG(GetSockName() + ": No cert");
		CallSockError(errnoBadSSLCert, "Anonymous SSL cert is not allowed");
		Close();
		return;
	}
	CString sHostVerifyError;
	if (!ZNC_SSLVerifyHost(m_HostToVerifySSL, pCert, sHostVerifyError)) {
		m_ssCertVerificationErrors.insert(sHostVerifyError);
	}
	X509_free(pCert);
	if (m_ssCertVerificationErrors.empty()) {
		DEBUG(GetSockName() + ": Good cert");
		return;
	}
	CString sFP = GetSSLPeerFingerprint();
	if (m_ssTrustedFingerprints.count(sFP) != 0) {
		DEBUG(GetSockName() + ": Cert explicitly trusted by user: " << sFP);
		return;
	}
	DEBUG(GetSockName() + ": Bad cert");
	CString sErrorMsg = "Invalid SSL certificate: ";
	sErrorMsg += CString(", ").Join(begin(m_ssCertVerificationErrors), end(m_ssCertVerificationErrors));
	CallSockError(errnoBadSSLCert, sErrorMsg);
	Close();
}
开发者ID:TuffLuck,项目名称:znc,代码行数:32,代码来源:Socket.cpp

示例2: DEBUG

bool CSocket::Connect(const CString& sHostname, unsigned short uPort, bool bSSL, unsigned int uTimeout
#ifdef HAVE_SHOES
		, const CString& sSocksAddr, unsigned short uSocksPort
#endif /* HAVE_SHOES */
) {
	if (!m_pModule) {
		DEBUG("ERROR: CSocket::Connect called on instance without m_pModule handle!");
		return false;
	}

	CUser* pUser = m_pModule->GetUser();
	CString sSockName = "MOD::C::" + m_pModule->GetModName();
	CString sBindHost;

	if (pUser) {
		sSockName += "::" + pUser->GetUserName();
		sBindHost = m_pModule->GetUser()->GetBindHost();
	}

	// Don't overwrite the socket name if one is already set
	if (!GetSockName().empty()) {
		sSockName = GetSockName();
	}

	return m_pModule->GetManager()->Connect(sHostname, uPort, sSockName, uTimeout, bSSL, sBindHost, this
#ifdef HAVE_SHOES
		, sSocksAddr, uSocksPort
#endif /* HAVE_SHOES */
	);
}
开发者ID:eatnumber1,项目名称:znc,代码行数:30,代码来源:Socket.cpp

示例3: DEBUG

bool CSocket::Connect(const CString& sHostname, unsigned short uPort, bool bSSL, unsigned int uTimeout) {
	if (!m_pModule) {
		DEBUG("ERROR: CSocket::Connect called on instance without m_pModule handle!");
		return false;
	}

	CUser* pUser = m_pModule->GetUser();
	CString sSockName = "MOD::C::" + m_pModule->GetModName();
	CString sBindHost;

	if (pUser) {
		sSockName += "::" + pUser->GetUserName();
		sBindHost = pUser->GetBindHost();
		CIRCNetwork* pNetwork = m_pModule->GetNetwork();
		if (pNetwork) {
			sSockName += "::" + pNetwork->GetName();
			sBindHost = pNetwork->GetBindHost();
		}
	}

	// Don't overwrite the socket name if one is already set
	if (!GetSockName().empty()) {
		sSockName = GetSockName();
	}

	m_pModule->GetManager()->Connect(sHostname, uPort, sSockName, uTimeout, bSSL, sBindHost, this);
	return true;
}
开发者ID:TuffLuck,项目名称:znc,代码行数:28,代码来源:Socket.cpp

示例4: DEBUG

void CDCCBounce::ReadLine(const CString& sData) {
    CString sLine = sData.TrimRight_n("\r\n");

    DEBUG(GetSockName() << " <- [" << sLine << "]");

    PutPeer(sLine);
}
开发者ID:sorbits,项目名称:znc,代码行数:7,代码来源:bouncedcc.cpp

示例5: BEG_FUNC

/**
 *  @brief      Attach this VSocket to a pre-existing socket handle.
 *
 *  @remarks    Attaches this object to an existing socket handle and
 *              enters the processing loop.
 *
 *  @param      pHandle
 *                  Handle to the socket to attach to.
 *------------------------------------------------------------------*/
bool VSocket::Attach(SOCKET pHandle) {
	char    vAddress[51];
	VUSHORT vPort = 0;

	BEG_FUNC("Attach")("%d", pHandle);

	if (mStatus == SS_CONNECTED) {
		VTRACE("Error-socket already connected to %s:%d\n",
				mEndPoint.GetAddr(), mEndPoint.GetPort());
		mError = EISCONN;
		return END_FUNC(false);
	}

	if (mStatus == SS_BOUND) {
		VTRACE("Error-socket already bound to %s:%d\n",
				mLocal.GetAddr(), mLocal.GetPort());
		mError = EISCONN;
		return END_FUNC(false);
	}

	mStatus = SS_ALLOCATED;
	mHandle = pHandle;
	GetPeerName(vAddress, 50, &vPort);
	mEndPoint.SetPort(vPort);
	mEndPoint.SetAddr(vAddress);

	memset(vAddress, 0, 50);
	GetSockName(vAddress, 50, &vPort);
	mLocal.SetPort(vPort);
	mLocal.SetAddr(vAddress);

	mStatus = SS_CONNECTED;

	return END_FUNC(true);
}
开发者ID:t3hpr1m3,项目名称:vutils,代码行数:44,代码来源:VSocket.cpp

示例6: memset

bool CSocket::GetSockName(SOCKADDR_IN* lpSockInAddr)
{
	memset(lpSockInAddr, 0, sizeof(SOCKADDR_IN));

	socklen_t nSockAddrLen = sizeof(SOCKADDR_IN);
	return GetSockName((SOCKADDR*)lpSockInAddr, &nSockAddrLen);
}
开发者ID:EISALab,项目名称:AMGAgroundwater,代码行数:7,代码来源:netsock.cpp

示例7: DEBUG

bool CRealListener::ConnectionFrom(const CString& sHost, unsigned short uPort) {
    bool bHostAllowed = CZNC::Get().IsHostAllowed(sHost);
    DEBUG(GetSockName() << " == ConnectionFrom(" << sHost << ", " << uPort
                        << ") [" << (bHostAllowed ? "Allowed" : "Not allowed")
                        << "]");
    return bHostAllowed;
}
开发者ID:Adam-,项目名称:znc,代码行数:7,代码来源:Listener.cpp

示例8: DEBUG

void CSocket::ReachedMaxBuffer() {
    DEBUG(GetSockName() << " == ReachedMaxBuffer()");
    if (m_pModule)
        m_pModule->PutModule(
            "Some socket reached its max buffer limit and was closed!");
    Close();
}
开发者ID:DarthGandalf,项目名称:znc,代码行数:7,代码来源:Socket.cpp

示例9: GetSockName

void CGnuLocal::JoinLan(CString LanName)
{
	m_pPrefs->m_LanName = LanName;


	CString LocalHost;
	UINT nPort;
	GetSockName(LocalHost, nPort);

	std::map<int, LanNode>::iterator itLanNode;
	for(itLanNode = m_LanNodeIDMap.begin(); itLanNode != m_LanNodeIDMap.end(); itLanNode++)
		if(itLanNode->second.Name == LanName)
		{
			Node PermNode;
			PermNode.Host = itLanNode->second.Host;
			PermNode.Port = itLanNode->second.Port;
			
			if(PermNode.Host != LocalHost)
				m_pComm->m_pCache->m_GnuPerm.push_back(PermNode);
		}

	m_pCore->Disconnect(NETWORK_GNUTELLA);
	m_pCore->Disconnect(NETWORK_G2);

	m_pCore->Connect(NETWORK_GNUTELLA);
}
开发者ID:swax,项目名称:GnucDNA,代码行数:26,代码来源:GnuLocal.cpp

示例10: DEBUG

void CSocket::SockError(int iErrno) {
	DEBUG(GetSockName() << " == SockError(" << strerror(iErrno) << ")");
	if (iErrno == EMFILE) {
		// We have too many open fds, this can cause a busy loop.
		Close();
	}
}
开发者ID:luser,项目名称:znc,代码行数:7,代码来源:Socket.cpp

示例11: ASSERT

//passive send CM_PASSIVE command, the server should return the passive data channel address
bool CServerSession::OnPassive( CNcpMessage* pMsg, int nBufSize )
{
    ASSERT( pMsg->GetCmd()==CM_PASSIVE );

    //create the passive socket if it not yet
    if( m_datasock==0 ) {
        m_datasock = Socket( PF_INET, SOCK_STREAM, 0 );
        SOCKADDR_IN sockaddr;
        sockaddr.sin_family = AF_INET;
        sockaddr.sin_port = 0;
        sockaddr.sin_addr.s_addr = INADDR_ANY;
        Bind( m_datasock, (SOCKADDR*)&sockaddr, sizeof(SOCKADDR_IN) );
        Listen( m_datasock, 5 );
    }

    //send the socket address informaton back to the client
    SOCKADDR_IN sockaddr;
    socklen_t nlen = sizeof(SOCKADDR_IN);
    GetSockName( m_datasock, (SOCKADDR*)&sockaddr, &nlen );

    //first is IN_ADDR, then is port number.
    pMsg->Init( CM_ACK );
    short *pport = (short*)( pMsg->GetData() );
    *pport = sockaddr.sin_port;

    pMsg->SetDataSize( sizeof(short) );
    pMsg->Send( m_sock );

    return true;
}
开发者ID:EISALab,项目名称:MIIGAgroundwater,代码行数:31,代码来源:ncpsession.cpp

示例12: GetSockName

void
Socket::SetIpTos (uint8_t tos)
{
  Address address;
  GetSockName (address);
  m_manualIpTos = true;
  m_ipTos = tos;
}
开发者ID:shuiziliuBUPT,项目名称:HelloWorld,代码行数:8,代码来源:socket.cpp

示例13: DEBUG

void CRealListener::SockError(int iErrno) {
	DEBUG(GetSockName() << " == SockError(" << strerror(iErrno) << ")");
	if (iErrno == EMFILE) {
		// We have too many open fds, let's close this listening port to be able to continue
		// to work, next rehash will (try to) reopen it.
		Close();
	}
}
开发者ID:Affix,项目名称:znc,代码行数:8,代码来源:Listener.cpp

示例14: DzGetSockName

int DzGetSockName( int fd, struct sockaddr* addr, socklen_t* addrLen )
{
    DzHost* host = GetHost();
    assert( host );
    assert( fd >= 0 );
    assert( ( fd & HANDLE_HOST_ID_MASK ) == host->hostId );

    return GetSockName( host, fd, addr, addrLen );
}
开发者ID:Foreverflying,项目名称:DzCot,代码行数:9,代码来源:DzCot.c

示例15: DEBUG

void CDCCSock::Connected() {
	DEBUG(GetSockName() << " == Connected(" << GetRemoteIP() << ")");
	m_pModule->PutModule(((m_bSend) ? "DCC -> [" : "DCC <- [") + m_sRemoteNick + "][" + m_sFileName + "] - Transfer Started.");

	if (m_bSend) {
		SendPacket();
	}

	SetTimeout(120);
}
开发者ID:BGCX261,项目名称:znc-msvc-svn-to-git,代码行数:10,代码来源:dcc.cpp


注:本文中的GetSockName函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。