SDL networking problem

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);


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//Server side

IPaddress ip;
UDPsocket server;
UDPpacket *p;

SDLNet_Init();
p = SDLNet_AllocPacket(1024);
server = SDLNet_UDP_Open(2000);

if(SDLNet_UDP_Recv(server, p))
{ 
      string Data = (char*)p->data;
      stringstream SS(Data);

      string Type;
      SS >> Type;

      if(Type == "Connected")
      {		
	    cout << "User connected" << endl;
      }


Any ideas for why this could be happening are appreciated.
Last edited on
Are you sure there are no firewalls blocking the traffic? Is any of the computers behind a NAT?
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)
Topic archived. No new replies allowed.