首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

P2P 高手,接错过 RakNet NatPunchthrough 的,怎么连接客户度,紧急求救

2012-01-18 
P2P 高手,接错过 RakNet NatPunchthrough 的,如何连接客户度,紧急求救看了一下 RakNet 3.009 b 版本里面有

P2P 高手,接错过 RakNet NatPunchthrough 的,如何连接客户度,紧急求救
看了一下 RakNet 3.009 b 版本
里面有个 NatPunchthrough例子
其中 (S)ender 和(R)ecipient, 通过(F)acilitator 已经连接上了,现在的问题是
如何让 Sender 和 (R)ecipient通讯,我使用了一下语句
rakPeer->Send(szMsg,(const int) strlen(szMsg)+1,HIGH_PRIORITY, RELIABLE_ORDERED, 0, reciveAddress, false);
但是发现对方不能收到信息,请问为什么?望各位知道的高手拔刀相助

if (kbhit())
{
char ch=getch();
if (ch=='c' && (mode[0]=='s' || mode[0]=='S'))
{
//printf("Enter recipient IP: "); 
//gets(recipientIP);
//if (recipientIP[0]==0)
//strcpy(recipientIP, "127.0.0.1");
// Connect to the recipient by going through the facilitator, which for the purposes of this sample we can
// assume is the first system connected (GetSystemAddressFromIndex(0))

strcpy(recipientIP, IP_Reciver);
printf("connect recipient IP ");
natPunchthrough.Connect(recipientIP, 60064, 0, 0, rakPeer->GetSystemAddressFromIndex(0));
printf("Attempting connection.\n");
}
else if (ch=='q')
break;
else 
{
if(mode[0]=='s' || mode[0]=='S')
{
char szMsg[256];
printf("Enter you wand send message: "); 
gets(szMsg);
SystemAddress reciveAddress;
reciveAddress.port=60064;
reciveAddress.SetBinaryAddress(IP_Reciver);
printf("Send Reciver %s",reciveAddress.ToString());
bool bRet = rakPeer->Send(szMsg,(const int) strlen(szMsg)+1,HIGH_PRIORITY, RELIABLE_ORDERED, 0, reciveAddress, false);

}
}
}


[解决办法]
我没带刀! 下次。 我也在学这个呢。

热点排行