Hello, im currently developing a simple game using RakNet. Everything went fine until i tried connecting to the server when the server was on another PC.
Working as it should when using "localhost" but when using the IP on the remote computer it wont connect. I have checked with an network sniffer software that the packages arrives. Also tried with my own PC using my own IP instead of "localhost" and it wont work. Only works with "localhost", what am i doing wrong?
Basic server code:
const unsigned char MAX_CLIENTS = 10;
const unsigned int PORT = 2578;
PacketHandler pH;
// Set up server
RakPeerInterface *server = RakPeerInterface::GetInstance();
Packet * packet = NULL;
if(server->Startup(MAX_CLIENTS, &SocketDescriptor(PORT,""), 1) == RAKNET_STARTED)
{
cout << "Server started successfully.\n";
}
else
{
cout << "There was an error starting the server.\n";
return 0;
}
server->SetMaximumIncomingConnections(MAX_CLIENTS);
while (1)
{
for (packet=server->Receive(); packet; server->DeallocatePacket(packet), packet=server->Receive())
{
pH.handlePackage(server, packet);
}
}
server->Shutdown(300);
RakPeerInterface::DestroyInstance(server);
cout << "Server closed successfully.\n";
Basic game code:
#define SERVER_PORT 2578
#define SERVER_IP "localhost"
RakPeerInterface *client = RakPeerInterface::GetInstance();
Packet *packet;
client->Startup(1,&SocketDescriptor(), 1);
client->Connect(SERVER_IP, SERVER_PORT, 0,0);