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


C++ CAddress::GetAddress方法代码示例

本文整理汇总了C++中CAddress::GetAddress方法的典型用法代码示例。如果您正苦于以下问题:C++ CAddress::GetAddress方法的具体用法?C++ CAddress::GetAddress怎么用?C++ CAddress::GetAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CAddress的用法示例。


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

示例1: CPipeResult

CPipeConnectSuccResult::CPipeConnectSuccResult(
	int32 nPipeId, uint32 uSessionID, 
	const CAddress& LocalAddr, 
	const CAddress& RemoteAddr, CPipeThread* pThread)
	: CPipeResult(nPipeId, uSessionID)
{
	m_szLocalAddr = CloneString(LocalAddr.GetAddress(), pThread);
	m_uLocalPort = LocalAddr.GetPort();

	m_szRemoteAddr = CloneString(RemoteAddr.GetAddress(), pThread);
	m_uRemotePort = RemoteAddr.GetPort();
}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:12,代码来源:CPipeResult.cpp

示例2: CloneString

CPipeAcceptedResult::CPipeAcceptedResult(int32 nPipeId,uint32 uSessionID, int32 newPipeId, uint32 threadId, 
										 uint32 oldthreadid, IPipe* pPipe, const CAddress& LocalAddr, const CAddress& RemoteAddr, CPipeThread* pThread)
										 :CPipeResult(nPipeId, uSessionID)
{
	m_szLocalAddr = CloneString( LocalAddr.GetAddress(), pThread );
	m_uLocalPort = LocalAddr.GetPort();

	m_szRemoteAddr = CloneString( RemoteAddr.GetAddress(), pThread );
	m_uRemotePort = RemoteAddr.GetPort();

	m_pPipe = pPipe;
	m_uOldThreadId = oldthreadid;
	m_nNewPipeID = newPipeId;
	m_uThreadId = threadId;
}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:15,代码来源:CPipeResult.cpp

示例3: ShutDown

void CConnClient::ShutDown(const char* szMsg)
{
	if(m_bShutting)
		return;
	m_bShutting = true;
	CCoreSceneMgrClient::Inst()->DestroyMainSceneIfNotBeingUsedByLogic();
	CTimeSystemClient::Inst()->UnRegister(this);
	if (IntShutDown() && szMsg)
	{
		ostringstream strm;
		CAddress addr;
		const char* szUserName = GetValue("UserName");
		szUserName = szUserName?szUserName:"";
		GetLocalAddress(addr);
		LogTime(strm);
		strm << " account:" << szUserName << " reason:" << szMsg << " localip:" << addr.GetAddress() << " remoteip: " << endl;
		LogOnOffLineMsg(strm.str().c_str());
	}
	Inst()=NULL;
}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:20,代码来源:CConnClient.cpp

示例4: CreateBindedSocket

int CPipeState_Listening::CreateBindedSocket(SOCKET& SocketOut,const CAddress& Address)
{
	SOCKET Socket=CreateSocket();

	sockaddr_in saiAddress;
	memset(&saiAddress,0,sizeof(saiAddress));

	saiAddress.sin_addr.s_addr = inet_addr( Address.GetAddress() );
	saiAddress.sin_port = htons( static_cast<u_short>( Address.GetPort() ) );
	saiAddress.sin_family = AF_INET;

	//bind
	if( bind( Socket,reinterpret_cast<sockaddr*>( &saiAddress) , sizeof(sockaddr) ) )
	{
		closesocket(Socket);
		return SocketGetLastError();
	}

	SocketOut=Socket;
	return 0;
}
开发者ID:LaoZhongGu,项目名称:RushGame,代码行数:21,代码来源:CPipeState_Listening.cpp

示例5: GetPipe

CPipeState_Connecting::CPipeState_Connecting(CSyncPipe* pPipe,const CAddress& Address,uint32& uResult)
    :CPipeState_Busy(pPipe)
{
    pPipe->m_OutBuffer.OutBufferClear();
    pPipe->m_InBuffer.InBufferClear();

    CPipeState* pState=GetPipe()->m_pState;
    GetPipe()->m_pState=NULL;
    delete pState;
    GetPipe()->m_pState=this;

    const SOCKET& Socket=m_Socket;

#ifdef _WIN32
    SQR_TRY
    {
        m_Event.Create(Socket);
    }
    SQR_CATCH (exp)
    {
        LogExp(exp);
        closesocket(m_Socket);
        throw;
    }
    SQR_TRY_END;
#endif

    Register();

    sockaddr_in saiAddress;
    ::memset(&saiAddress,0,sizeof(saiAddress));

    saiAddress.sin_addr.s_addr = inet_addr(Address.GetAddress());
    saiAddress.sin_port = htons(static_cast<u_short>(Address.GetPort()));
    saiAddress.sin_family = AF_INET;


    //连接
    int nResult;

    nResult=connect(Socket,reinterpret_cast<sockaddr*>(&saiAddress),sizeof(sockaddr));

    if(SOCKET_ERROR!=nResult)
    {
        uResult=0;
    }
    else
    {
        int nError=SocketGetLastError();
        switch(nError)
        {
#if defined(__linux__)
        case EINPROGRESS:
#elif defined(_WIN32)
        case EWOULDBLOCK:
#endif
            uResult=1;
            break;
#ifdef _WIN32
        case ECONNABORTED://Windows下还真会出现这种情况
        case ENOBUFS:
            uResult=2;
            GetPipe()->AddEventConnectFailed(ePCFR_OSERROR);
            return;
#endif
        case ECONNRESET:
        case ECONNREFUSED:
            uResult=2;
            GetPipe()->AddEventConnectFailed(ePCFR_REFUSED);
            return;
        case ETIMEDOUT:
        case ENETRESET:
        case EHOSTUNREACH:
        case ENETUNREACH:
            uResult=2;
            GetPipe()->AddEventConnectFailed(ePCFR_UNREACHABLE);
            return;
        default:
            closesocket(m_Socket);
            stringstream strm;
            strm<<"connect failed with error code "<<nError<<".";
            GenErr(strm.str());
        }
    }

    m_RemoteAddress=Address;
}
开发者ID:svn2github,项目名称:ybtx,代码行数:87,代码来源:CPipeState_Connecting.cpp


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