Esempio n. 1
0
//-----------------------------------------------------------------------------------
//		Purpose	:
//		Return	:
//-----------------------------------------------------------------------------------
bool CNtlConnection::GetAddressInfo(CNtlString * pString, WORD * pPort, bool bRemote /* = true */)
{
	if( bRemote )
	{
		pString->GetString().assign( GetRemoteAddr().GetDottedAddr() );
		*pPort = GetRemoteAddr().GetPort();
	}
	else
	{
		pString->GetString().assign( GetLocalAddr().GetDottedAddr() );
		*pPort = GetLocalAddr().GetPort();
	}

	return true;
}
Esempio n. 2
0
bool Connections::GetAddressInfo(GameString* String, WORD * Port, bool Remote)
{
    if (Remote)
    {
        String->GetString().assign(GetRemoteAddr().GetDottedAddr());
        *Port = GetRemoteAddr().GetPort();
    }
    else
    {
        String->GetString().assign(GetLocalAddr().GetDottedAddr());
        *Port = GetLocalAddr().GetPort();
    }

    return true;
}
Esempio n. 3
0
bool NetResMgr::TcpGetRemoteAddr(TcpHandle handle, char ip[16], int& port) {
  auto socket = GetTcpSocket(handle);
  if (!socket) {
    LOG(kError, "TcpGetRemoteAddr failed: can not find handle %u.", handle);
    return false;
  }
  std::string ip_string;
  if (!socket->GetRemoteAddr(ip_string, port)) {
    return false;
  }
  strcpy_s(ip, 16, ip_string.c_str());
  return true;
}