• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetSockName函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: GetSockName

otError UdpSocket::SendTo(Message &aMessage, const MessageInfo &aMessageInfo)
{
    otError error = OT_ERROR_NONE;
    MessageInfo messageInfoLocal;
    UdpHeader udpHeader;

    messageInfoLocal = aMessageInfo;

    if (messageInfoLocal.GetSockAddr().IsUnspecified())
    {
        messageInfoLocal.SetSockAddr(GetSockName().GetAddress());
    }

    if (GetSockName().mPort == 0)
    {
        GetSockName().mPort = static_cast<Udp *>(mTransport)->GetEphemeralPort();
    }

    if (messageInfoLocal.GetPeerAddr().IsUnspecified())
    {
        VerifyOrExit(!GetPeerName().GetAddress().IsUnspecified(), error = OT_ERROR_INVALID_ARGS);

        messageInfoLocal.SetPeerAddr(GetPeerName().GetAddress());
    }

    if (messageInfoLocal.mPeerPort == 0)
    {
        VerifyOrExit(GetPeerName().mPort != 0, error = OT_ERROR_INVALID_ARGS);
        messageInfoLocal.mPeerPort = GetPeerName().mPort;
    }

    udpHeader.SetSourcePort(GetSockName().mPort);
    udpHeader.SetDestinationPort(messageInfoLocal.mPeerPort);
    udpHeader.SetLength(sizeof(udpHeader) + aMessage.GetLength());
    udpHeader.SetChecksum(0);

    SuccessOrExit(error = aMessage.Prepend(&udpHeader, sizeof(udpHeader)));
    aMessage.SetOffset(0);
    SuccessOrExit(error = static_cast<Udp *>(mTransport)->SendDatagram(aMessage, messageInfoLocal, kProtoUdp));

exit:
    return error;
}
开发者ID:lanyuwen,项目名称:openthread,代码行数:43,代码来源:udp6.cpp


示例17: Bind

otError UdpSocket::Bind(const SockAddr &aSockAddr)
{
    mSockName = aSockAddr;

    if (GetSockName().mPort == 0)
    {
        mSockName.mPort = static_cast<Udp *>(mTransport)->GetEphemeralPort();
    }

    return OT_ERROR_NONE;
}
开发者ID:lanyuwen,项目名称:openthread,代码行数:11,代码来源:udp6.cpp


示例18: DEBUG

void CRealListener::SockError(int iErrno, const CString& sDescription) {
	DEBUG(GetSockName() << " == SockError(" << sDescription << ", " << 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.
		CZNC::Get().Broadcast("We hit the FD limit, closing listening socket on ["
				+ GetLocalIP() + " : " + CString(GetLocalPort()) + "]");
		CZNC::Get().Broadcast("An admin has to rehash to reopen the listening port");
		Close();
	}
}
开发者ID:James-TR,项目名称:znc,代码行数:11,代码来源:Listener.cpp


示例19: GetListenPort

/*========================================================================================
	FUNCTION: LBaseSock::GetListenPort()
	DESCRIPT: Get the listening port #.
	RETURN	:
	ARGUMENT: None
	UPDATE	: 2004/07/01, In-hyeok Paek; First work!
========================================================================================*/
int LBaseSock::GetListenPort()
{
	CString		sAddr;	//	IP address
	unsigned int	nPort;	//	Port #

	if( !GetSockName( sAddr, nPort ) ) { return nPort; }
	else {
		TRACE( "Socket get peer name failed: %d - %s\n", m_nLastErr, 
			   GetLastErrorString() );
		return m_nLastErr;
	}
}
开发者ID:japgo,项目名称:mygithub,代码行数:19,代码来源:LBaseSock.cpp


示例20: GetSockName

bool CSocket::GetSockName(string& rSocketAddress, UINT& rSocketPort)
{
	SOCKADDR_IN sockAddr;

	bool bResult = GetSockName(&sockAddr);
	if (bResult)
	{
		rSocketPort = ntohs(sockAddr.sin_port);
		rSocketAddress = inet_ntoa(sockAddr.sin_addr);
	}
	return bResult;
}
开发者ID:EISALab,项目名称:AMGAgroundwater,代码行数:12,代码来源:netsock.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetSocket函数代码示例发布时间:2022-05-30
下一篇:
C++ GetSlot函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap