For the last few days I have been practicing basic networking using SDL_net. I have managed to create a server and have users connect to it (the server is running on my computer right now), however when I try and run the client from this computer (the same computer the server is on) it wont connect.
The same thing happens when I try and give the server to someone else, I am able to connect to it but they can't from their computer. Here is the simplified code for it (Removed some error checking etc to make it shorter).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
//Client side
IPaddress ip;
UDPsocket server;
UDPpacket *p;
p = SDLNet_AllocPacket(1024);
server = SDLNet_UDP_Open(0)
SDLNet_ResolveHost(&ip,IP, 2000); // IP is defined earlier
strcpy((char*)p->data,"Connected");
p->len = strlen((char*)p->data) + 1;
p->address.host = ip.host;
p->address.port = ip.port;
SDLNet_UDP_Send(server, -1, p);
Interesting, I have never heard of NAT before (my general internet knowledge is not great) however I excluded my local IP from it under my internet settings and it seems to have fixed the problem.
Thanks a lot for the help :D
(Now to go and research more about it)