本文整理汇总了C++中raknet::SystemAddress::ToString方法的典型用法代码示例。如果您正苦于以下问题:C++ SystemAddress::ToString方法的具体用法?C++ SystemAddress::ToString怎么用?C++ SystemAddress::ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类raknet::SystemAddress
的用法示例。
在下文中一共展示了SystemAddress::ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
void Network_module::run()
{
print_config();
using namespace RakNet;
int l_addr_count = m_rakpeer->GetNumberOfAddresses();
NET_MOD_INFO("获取到本机IP数量%d个", l_addr_count);
for (int i = 0; i < l_addr_count; i++)
{
RakNet::SystemAddress addr = m_rakpeer->GetLocalIP(i);
NET_MOD_INFO("第%d个IP地址为:%s", i + 1, addr.ToString(false));
}
RakNet::SocketDescriptor l_socket_descriptor;
l_socket_descriptor.port = m_local_port;
if (m_rakpeer->Startup(m_max_connection, &l_socket_descriptor, 1) != RakNet::RAKNET_STARTED)
{
NET_MOD_ERROR("启动网络引擎失败");
RakNet::RakPeerInterface::DestroyInstance(m_rakpeer);
return;
}
m_rakpeer->SetMaximumIncomingConnections(m_max_income_connection);
NET_MOD_INFO("启动网络引擎成功,监控地址为%s", m_rakpeer->GetMyBoundAddress().ToString(false));
NET_MOD_INFO("开始载入打孔插件");
m_punch_proxy->init_proxy(m_rakpeer);
if (m_rakpeer->Connect(DEFAULT_SERVER_IP, DEFAULT_SERVER_PORT, 0, 0) != RakNet::CONNECTION_ATTEMPT_STARTED)
{
NET_MOD_ERROR("网络引擎,尝试连接失败");
return;
}
NET_MOD_INFO("尝试连接服务器IP地址为%s,端口为%d", DEFAULT_SERVER_IP, DEFAULT_SERVER_PORT);
RakNet::Packet* packet = NULL;
int flag = true;
while (flag)
{
for (packet=m_rakpeer->Receive(); packet; m_rakpeer->DeallocatePacket(packet), packet=m_rakpeer->Receive())
{
if (packet->data[0]==ID_CONNECTION_REQUEST_ACCEPTED)
{
NET_MOD_INFO("连接服务器%s:%d成功", DEFAULT_SERVER_IP, DEFAULT_SERVER_PORT);
if (m_server_addr)
{
delete m_server_addr;
}
m_server_addr = new RakNet::SystemAddress;
*m_server_addr = packet->systemAddress;
flag = false;
break;
}
else
{
NET_MOD_ERROR("连接服务器失败");
return;
}
}
}
start_network_loop();
}