Hi there.
I'm currently developing the online multiplayer for my college project. We have to develop it using RakNet library.
Now I am have successfully developed a server and client that can communicate from machines connected into the same network. The next step in the development that I want to make is to accomplish remote connections between clients and the server. I have read the docummentation of RakNet. As I have understood, there is no need to make IP forwarding, because NATPunchthrough plugin resolves the problem. I have followed the guidelines in the official webpage to make the basic connection. However, it doesn't work. I mean, the connection packet that de client sends to the public IP isn't recevied by the server, so I can't make any steps further (because i have to run the OpenNAT function after receiving the connection acceptance packet).
I tried to bind the public IP to the server, as I have seen in the forums with strcpy(socket.host, public_ip), but it just triggers an error and sets it to it's default.
I want to ask you if I am missing something or misunderstanding any concept.
Here's my code for the server, the part that corresponds on binding:
m_natPunch_ptr = RakNet::NatPunchthroughServer::GetInstance();
m_peerInterface_ptr = RakNet::RakPeerInterface::GetInstance();
m_peerInterface_ptr->AttachPlugin(m_natPunch_ptr);
m_socketDescriptor_sock = RakNet::SocketDescriptor(m_SERVERPORT_i, 0);
m_peerInterface_ptr->Startup(m_MAXCONNECTIONS_i,&m_socketDescriptor_sock,1);
m_peerInterface_ptr->SetMaximumIncomingConnections(m_MAXCONNECTIONS_i);
std::cout<<"[SUCCESS] - Server initialized correctly"<<std::endl;
std::cout<<"The server GUID is ->"<<m_peerInterface_ptr->GetMyGUID().ToString()<<std::endl;
std::cout<<"The server IP is ->"<<m_peerInterface_ptr->GetSystemAddressFromGuid(m_peerInterface_ptr->GetMyGUID()).ToString()<<std::endl;
And here's the client corresponding one:
m_punchClient_ptr = RakNet::NatPunchthroughClient::GetInstance();
m_peerInterface_ptr = RakNet::RakPeerInterface::GetInstance();
m_peerInterface_ptr->AttachPlugin(m_punchClient_ptr);
m_peerInterface_ptr->Startup(1,&m_socketDescriptor_sock,1);
ConnectToServer();
std::cout<<"I'm going to try to connect to the server"<<std::endl;
m_peerInterface_ptr->Connect("My public IP",8000,0,0); //I retrieve my public IP with whatspmyip.com
std::cout<<"Connecting..."<<std::endl;
Thank you very much in advance.