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


C++ GetSocketID函数代码示例

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


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

示例1: SetCheckConnect

void CSSLClientAsync::OnConnect(BOOL bConnected)
{
    //无论是否连接成功,都认为已经判断结束
    SetCheckConnect(FALSE);
    //连接完毕,则删除写/错误事件的注册,改成读事件
    m_pio->Remove_WriteEvent(this);
    if (TRUE == bConnected)
    {
        SOCKET_IO_INFO("socket connect successed, remote ip: %s, port: %d.", GetRemoteIP(),
                       GetRemotePort());
        DoConnect(GetSocketID());
        SSL_set_mode(GetSSL(), SSL_MODE_AUTO_RETRY);
        if (SSL_set_fd(GetSSL(), GetSocket()) != 1)
        {
            SOCKET_IO_ERROR("ssl set fd failed");
            DoException(GetSocketID(), SOCKET_IO_SSL_CONNECT_FAILED);
            return;
        }
        SSLConnect();
    }
    else
    {
        SOCKET_IO_ERROR("socket connect failed, remote ip: %s, port: %d.", GetRemoteIP(), GetRemotePort());
        DoException(GetSocketID(), SOCKET_IO_TCP_CONNECT_FAILED);
    }
}
开发者ID:shiwei0124,项目名称:common_code,代码行数:26,代码来源:ssl_client_async.cpp

示例2: result

void CUser::SelCharToAgent(Packet & pkt)
{
	Packet result(WIZ_SEL_CHAR);
	std::string strUserID, strAccountID;
	uint8 bInit;

	pkt >> strAccountID >> strUserID >> bInit;
	if (strAccountID.empty() || strAccountID.size() > MAX_ID_SIZE
		|| strUserID.empty() || strUserID.size() > MAX_ID_SIZE
		||strAccountID != m_strAccountID)
	{
		Disconnect();
		return;
	}

	// Disconnect any currently logged in sessions.
	CUser *pUser = g_pMain->GetUserPtr(strUserID.c_str(), TYPE_CHARACTER);
	if (pUser && (pUser->GetSocketID() != GetSocketID()))
	{
		pUser->Disconnect();

		// And reject the login attempt (otherwise we'll probably desync char data)
		result << uint8(0);
		Send(&result);
		return;
	}

	result << m_strAccountID << strUserID << bInit;
	g_pMain->m_LoggerSendQueue.PutData(&result, GetSocketID());
}
开发者ID:DACRepair,项目名称:snoxd-koserver-1,代码行数:30,代码来源:CharacterSelectionHandler.cpp

示例3: result

void CUser::UserInOut(BYTE Type)
{
	if (GetMap() == NULL)
		return;

	Packet result(WIZ_USER_INOUT);
	result << Type << uint8(0) << uint16(GetSocketID());

	if (Type == USER_OUT)
		GetMap()->RegionUserRemove(m_RegionX, m_RegionZ, GetSocketID());
	else
		GetMap()->RegionUserAdd(m_RegionX, m_RegionZ, GetSocketID());

	if (Type != USER_OUT)
		GetUserInfo(result);

	m_pMain->Send_Region(&result, GetMap(), m_RegionX, m_RegionZ, this );

	if (Type == USER_OUT || m_bAbnormalType != ABNORMAL_BLINKING) 
	{
		result.Initialize(AG_USER_INOUT);
		result.SByte();
		result << Type << uint16(GetSocketID()) << m_pUserData->m_id << m_pUserData->m_curx << m_pUserData->m_curz;
		m_pMain->Send_AIServer(&result);
	}
}
开发者ID:koray10,项目名称:snoxd-koserver,代码行数:26,代码来源:CharacterMovementHandler.cpp

示例4: ASSERT

void CUser::MoveProcess(Packet & pkt)
{
	ASSERT(GetMap() != nullptr);
	if (m_bWarp || isDead()) 
		return;

	uint16 will_x, will_z, will_y;
	int16 speed=0;
	float real_x, real_z, real_y;
	uint8 echo;

	pkt >> will_x >> will_z >> will_y >> speed >> echo;
	real_x = will_x/10.0f; real_z = will_z/10.0f; real_y = will_y/10.0f;

	if (!isGM())
	{
		// TO-DO: Handle proper speed checks against server-side amounts.
		// We should also avoid relying on what the client has sent us.
		if (speed > 200)	// What is the signifance of this number? Considering 90 is light feet...
			// We shouldn't be using magic numbers at all here.
		{
			Disconnect();
			return;
		}
	}

	if (!GetMap()->IsValidPosition(real_x, real_z, real_y)) 
		return;

	if (m_oldx != GetX()
		|| m_oldz != GetZ())
	{
		m_oldx = GetX();
		m_oldy = GetY();
		m_oldz = GetZ();
	}

	// TO-DO: Ensure this is checked properly to prevent speedhacking
	SetPosition(real_x, real_y, real_z);

	if (RegisterRegion())
	{
		g_pMain->RegionNpcInfoForMe(this);
		g_pMain->RegionUserInOutForMe(this);
		g_pMain->MerchantUserInOutForMe(this);
	}

	if (m_bInvisibilityType == INVIS_DISPEL_ON_MOVE)
		CMagicProcess::RemoveStealth(this, INVIS_DISPEL_ON_MOVE);

	Packet result(WIZ_MOVE);
	result << GetSocketID() << will_x << will_z << will_y << speed << echo;
	SendToRegion(&result);

	GetMap()->CheckEvent(real_x, real_z, this);

	result.Initialize(AG_USER_MOVE);
	result << GetSocketID() << m_curx << m_curz << m_cury << speed;
	Send_AIServer(&result);
}
开发者ID:asis21,项目名称:koserver,代码行数:60,代码来源:CharacterMovementHandler.cpp

示例5: ADDTOCALLSTACK

bool CClient::addRelay( const CServerDef * pServ )
{
	ADDTOCALLSTACK("CClient::addRelay");
	EXC_TRY("addRelay");

	// Tell the client to play on this server.
	if ( !pServ )
		return false;

	CSocketAddressIP ipAddr = pServ->m_ip;

	if ( ipAddr.IsLocalAddr())	// local server address not yet filled in.
	{
		ipAddr = m_net->m_socket.GetSockName();
		DEBUG_MSG(( "%x:Login_Relay to %s\n", GetSocketID(), ipAddr.GetAddrStr() ));
	}

	if ( GetPeer().IsLocalAddr() || GetPeer().IsSameIP( ipAddr ))	// weird problem with client relaying back to self.
	{
		DEBUG_MSG(( "%x:Login_Relay loopback to server %s\n", GetSocketID(), ipAddr.GetAddrStr() ));
		ipAddr.SetAddrIP( SOCKET_LOCAL_ADDRESS );
	}

	EXC_SET("customer id");
	dword dwAddr = ipAddr.GetAddrIP();
	dword dwCustomerId = 0x7f000001;
	if ( g_Cfg.m_fUseAuthID )
	{
		CSString sCustomerID(pServ->GetName());
		sCustomerID.Add(GetAccount()->GetName());

		dwCustomerId = z_crc32(0L, Z_NULL, 0);
		dwCustomerId = z_crc32(dwCustomerId, reinterpret_cast<const z_Bytef *>(sCustomerID.GetPtr()), (z_uInt)sCustomerID.GetLength());

		GetAccount()->m_TagDefs.SetNum("customerid", dwCustomerId);
	}

	DEBUG_MSG(( "%x:Login_Relay to server %s with AuthId %u\n", GetSocketID(), ipAddr.GetAddrStr(), dwCustomerId ));

	EXC_SET("server relay packet");
	new PacketServerRelay(this, dwAddr, pServ->m_ip.GetPort(), dwCustomerId);
	
	m_Targ_Mode = CLIMODE_SETUP_RELAY;
	return true;
	EXC_CATCH;

	EXC_DEBUG_START;
	g_Log.EventDebug("account '%s'\n", GetAccount() ? GetAccount()->GetName() : "");
	EXC_DEBUG_END;
	return false;
}
开发者ID:nefthon,项目名称:Source,代码行数:51,代码来源:CClientLog.cpp

示例6: ASSERT

void CUser::MoveProcess(Packet & pkt)
{
	ASSERT(GetMap() != nullptr);
	if (m_bWarp || isDead()) 
		return;

	uint16 will_x, will_z, will_y;
	int16 speed=0;
	float real_x, real_z, real_y;
	uint8 echo;

	pkt >> will_x >> will_z >> will_y >> speed >> echo;
	real_x = will_x/10.0f; real_z = will_z/10.0f; real_y = will_y/10.0f;

	m_sSpeed = speed;
	SpeedHackUser();

	if (!GetMap()->IsValidPosition(real_x, real_z, real_y)) 
		return;

	if (m_oldx != GetX()
		|| m_oldz != GetZ())
	{
		m_oldx = GetX();
		m_oldy = GetY();
		m_oldz = GetZ();
	}

	// TODO: Ensure this is checked properly to prevent speedhacking
	SetPosition(real_x, real_y, real_z);

	if (RegisterRegion())
	{
		g_pMain->RegionNpcInfoForMe(this);
		g_pMain->RegionUserInOutForMe(this);
		g_pMain->MerchantUserInOutForMe(this);
	}

	if (m_bInvisibilityType == INVIS_DISPEL_ON_MOVE)
		CMagicProcess::RemoveStealth(this, INVIS_DISPEL_ON_MOVE);

	Packet result(WIZ_MOVE);
	result << GetSocketID() << will_x << will_z << will_y << speed << echo;
	SendToRegion(&result);

	GetMap()->CheckEvent(real_x, real_z, this);

	result.Initialize(AG_USER_MOVE);
	result << GetSocketID() << m_curx << m_curz << m_cury << speed;
	Send_AIServer(&result);
}
开发者ID:BARBAROSS,项目名称:X-ShieldProject,代码行数:51,代码来源:CharacterMovementHandler.cpp

示例7: SSL_read

void CSSLClientAsync::OnRecv()
{
    if (GetSSLConnectStatus() == TRUE)
    {
        char szBuf[TCP_RECV_SIZE] = {0};
        int32_t nRet = SSL_read(GetSSL(), szBuf, TCP_RECV_SIZE);
        if (nRet > 0)
        {
            int32_t nBufSize = nRet;
            char szIP[32] = {0};
            int32_t nPort = 0;
            S_GetPeerName(GetSocket(), szIP, &nPort);
            DoRecv(GetSocketID(), szBuf, nBufSize, szIP, nPort);
        }
        else if (nRet == 0)
        {
            int32_t nErrorCode = SSL_get_error(GetSSL(), nRet);
            if (SSL_ERROR_ZERO_RETURN == nErrorCode)
            {
                //对方关闭socket
                SOCKET_IO_WARN("recv ssl data error, peer closed.");
                DoException(GetSocketID(), SOCKET_IO_SSL_RECV_FAILED);
            }
            else
            {
                SOCKET_IO_ERROR("recv ssl data error.");
                DoException(GetSocketID(), SOCKET_IO_SSL_RECV_FAILED);
            }
        }
        else
        {
            int32_t nErrorCode = SSL_get_error(GetSSL(), nRet);
            if (SSL_ERROR_WANT_READ == nErrorCode || SSL_ERROR_WANT_WRITE == nErrorCode)
            {
                //用select/epoll/iocp的方式应该很少会有这个情况出现
                SOCKET_IO_DEBUG("recv ssl data error, buffer is blocking.");
            }
            else
            {
                SOCKET_IO_ERROR("recv ssl data error, errno: %d.", nErrorCode);
                DoException(GetSocketID(), SOCKET_IO_SSL_RECV_FAILED);
            }
        }
    }
    else
    {
        SSLConnect();
    }
}
开发者ID:shiwei0124,项目名称:common_code,代码行数:49,代码来源:ssl_client_async.cpp

示例8: HPR_Recv

/**	@fn	void CTCPSession::OnRecv()
*	@brief 
*	@return	
*/
void CTCPSession::OnRecv()
{
	char szBuf[RECV_MAX_BUF_SIZE] = {0};
	HPR_INT32 nRet = HPR_Recv(GetSocket(), szBuf, RECV_MAX_BUF_SIZE);
	if (nRet > 0)
	{
		HPR_INT32 nBufSize = nRet;
		if (m_phandler != NULL)
		{
			HPR_ADDR_T addr;
			memset(&addr, 0, sizeof(HPR_ADDR_T));
			HPR_GetAddrBySockFd(GetSocket(), NULL, &addr);
			if (m_phandler != NULL)
			{
				m_phandler->OnRecv(GetSocketID(), szBuf, nBufSize, HPR_GetAddrString(&addr), HPR_GetAddrPort(&addr));
			}
		}
	}
	else if (nRet == 0)		
	{
		// close socket
		if (m_phandler != NULL)
		{
			m_phandler->OnException(GetSocketID(), LIB_DEV_ANALYSIS_ERROR_RECV);
		}
		DEV_ANALYSIS_DEBUG(0, "DEV ANALYSIS Debug", 0, 0,
			"dev analysis recv tcp data error, peer closed.");
	}
	else
	{
#if (defined(_WIN32) || defined(_WIN64))
		HPR_INT32 nErrorCode = ::GetLastError();
		if (nErrorCode != WSAEWOULDBLOCK)
#elif defined(__linux__)
		HPR_INT32 nErrorCode = errno;
		if (nErrorCode != EAGAIN)
#endif
		{

			DEV_ANALYSIS_DEBUG(0, "DEV ANALYSIS Debug", 0, 0,
				"dev analysis recv tcp data error, errno: %d.", nErrorCode);
			if (m_phandler != NULL)
			{
				m_phandler->OnException(GetSocketID(), LIB_DEV_ANALYSIS_ERROR_RECV);
			}
		}
	}
}
开发者ID:Strongc,项目名称:util_code,代码行数:52,代码来源:tcp_session.cpp

示例9: RemoveFromMerchantLookers

void CUser::BuyingMerchantList(Packet & pkt)
{
    if (m_sMerchantsSocketID >= 0)
        RemoveFromMerchantLookers(); //This check should never be hit...

    uint16 uid = pkt.read<uint16>();

    CUser *pMerchant = g_pMain->GetUserPtr(uid);
    if (pMerchant == nullptr
            || !pMerchant->isMerchanting())
        return;

    m_sMerchantsSocketID = uid;
    pMerchant->m_arMerchantLookers.push_front(GetSocketID());

    Packet result(WIZ_MERCHANT, uint8(MERCHANT_BUY_LIST));
    result << uint8(1) << uint16(uid);
    for (int i = 0; i < MAX_MERCH_ITEMS; i++)
    {
        _MERCH_DATA *pMerch = &pMerchant->m_arMerchantItems[i];
        result	<< pMerch->nNum << pMerch->sCount
                << pMerch->sDuration << pMerch->nPrice;
    }
    Send(&result);
}
开发者ID:berraktuzunatac,项目名称:snoxd-koserver,代码行数:25,代码来源:MerchantHandler.cpp

示例10: ResetGMVisibility

void CUser::UserInOut(uint8 bType)
{
	if (GetRegion() == nullptr)
		return;

	Packet result;

	if (bType != INOUT_OUT)
		ResetGMVisibility();

	GetInOut(result, bType);

	if (bType == INOUT_OUT)
		GetRegion()->Remove(this);
	else
		GetRegion()->Add(this);

	SendToRegion(&result, this, GetEventRoom());

	if (bType == INOUT_OUT || !isBlinking())
	{
		result.Initialize(AG_USER_INOUT);
		result.SByte();
		result << bType << GetSocketID() << GetName() << m_curx << m_curz;
		Send_AIServer(&result);
	}
}
开发者ID:R3aLisT,项目名称:X-ShieldProject,代码行数:27,代码来源:CharacterMovementHandler.cpp

示例11: result

void CUser::LoginProcess(Packet & pkt)
{
	// Enforce only one login request per session
	// It's common for players to spam this at the server list when a response isn't received immediately.
	if (!m_strAccountID.empty())
		return;

	Packet result(WIZ_LOGIN);
	CUser * pUser;
	std::string strAccountID, strPasswd;
	pkt >> strAccountID >> strPasswd;
	if (strAccountID.empty() || strAccountID.size() > MAX_ID_SIZE
		|| strPasswd.empty() || strPasswd.size() > MAX_PW_SIZE)
		goto fail_return;

	pUser = g_pMain->GetUserPtr(strAccountID, TYPE_ACCOUNT);
	if (pUser && (pUser->GetSocketID() != GetSocketID()))
	{
		pUser->Disconnect();
		goto fail_return;
	}

	result << strPasswd;
	m_strAccountID = strAccountID;
	g_pMain->AddDatabaseRequest(result, this);
	return;

fail_return:
	result << uint8(-1);
	Send(&result);
}
开发者ID:BlackStaRinc,项目名称:snoxd-koserver,代码行数:31,代码来源:LoginHandler.cpp

示例12: RemoveFromMerchantLookers

void CUser::MerchantItemList(Packet & pkt)
{
	if (m_sMerchantsSocketID >= 0)
		RemoveFromMerchantLookers(); //This check should never be hit...
	
	uint16 uid;
	pkt >> uid;

	if (uid >= MAX_USER)
		return;

	CUser *pMerchantUser = g_pMain->GetUserPtr(uid);
	if(!pMerchantUser || !pMerchantUser->isMerchanting())
		return;

	m_sMerchantsSocketID = uid;
	pMerchantUser->m_arMerchantLookers.push_front(GetSocketID());

	Packet result(WIZ_MERCHANT, uint8(MERCHANT_ITEM_LIST));
	result << uint16(1) << uint16(uid);
	for(int i = 0; i < MAX_MERCH_ITEMS; i++) {
		result << pMerchantUser->m_arSellingItems[i].nNum
		<< pMerchantUser->m_arSellingItems[i].sCount
		<< pMerchantUser->m_arSellingItems[i].sDuration
		<< pMerchantUser->m_arSellingItems[i].nPrice
		<< uint32(0); //Not sure what this one is, maybe serial?
	}
	Send(&result);
}
开发者ID:DACRepair,项目名称:snoxd-koserver-1,代码行数:29,代码来源:MerchantHandler.cpp

示例13: switch

long CMessage::DefaultRun()
{
	switch( GetType() )
	{
	case BASEMSG_Socket_Accept:
    {
    }
    break;

	case BASEMSG_Socket_Close:
    {
        NetFlag flag = (NetFlag)GetNetFlag();
        if (flag & NF_GAME_SERVER)
        {
            GetNetHandler().OnClientLost(GetGSID());
            CMessage::UnMapGSIDSocket(GetSocketID());
        }
        else
        {
            GetNetHandler().OnServerLost(flag);
        }
    }
    break;
	}

	return 0;
}
开发者ID:yuanxiubin1128,项目名称:mmo-resourse,代码行数:27,代码来源:Message.cpp

示例14: WSAAsyncSelect

//关闭连接
VOID CTCPSocket::CloseSocket(BYTE bNotify)
{
	//关闭连接
	bool bClose = (m_hSocket != INVALID_SOCKET);
	m_cbSocketStatus = SOCKET_STATUS_IDLE;
	if (m_hSocket != INVALID_SOCKET)
	{
		WSAAsyncSelect(m_hSocket, GetSafeHwnd(), WM_SOCKET_NOTIFY, 0);
		closesocket(m_hSocket);
		m_hSocket = INVALID_SOCKET;
		m_cbSocketStatus = SOCKET_STATUS_IDLE;
	}
	if ((bClose == true) && (m_pITCPSocketSink != NULL))
	{
		ASSERT(m_pITCPSocketSink != NULL);
		try
		{
			m_pITCPSocketSink->OnEventTCPSocketShut(GetSocketID(), bNotify);
		}
		catch (...) {}
	}

	//恢复数据
	m_wRecvSize = 0;
	m_cbSendRound = 0;
	m_cbRecvRound = 0;
	m_dwSendXorKey = 0;
	m_dwRecvXorKey = 0;
	m_dwSendTickCount = 0;
	m_dwRecvTickCount = 0;
	m_dwSendPacketCount = 0;
	m_dwRecvPacketCount = 0;
	m_hSocket = INVALID_SOCKET;
	m_cbSocketStatus = SOCKET_STATUS_IDLE;
}
开发者ID:Michael-Z,项目名称:qipai-game,代码行数:36,代码来源:TCPSocket.cpp

示例15: printf

void CGameSocket::RecvServerConnect(Packet & pkt)
{
	uint8 byReconnect = pkt.read<uint8>();
	printf("[GameServer connected - %s]\n", GetRemoteIP().c_str());

	Packet result(AI_SERVER_CONNECT, byReconnect);
	Send(&result);

	if (byReconnect == 1)
		TRACE("**** ReConnect - server=%s,  socket = %d ****\n ", GetRemoteIP().c_str(), GetSocketID());
	else
		TRACE("**** Connect - server=%s,  socket = %d ****\n ", GetRemoteIP().c_str(), GetSocketID());

	g_pMain->m_bFirstServerFlag = true;
	g_pMain->AllNpcInfo();
}
开发者ID:TheNewbGuy,项目名称:snoxd-koserver,代码行数:16,代码来源:GameSocket.cpp


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