Advertisement

cant connect to anything (sdl_net)

Started by January 29, 2006 10:12 PM
5 comments, last by raptorstrike 19 years ago
well i just spent the last 2-3 hrs trying to get this dumb sdl_net example to actually work, I failed. the problem is that it just wont connect to anything. I am going through a router but I have port forwarding enabled on the specified port number in code(not that that should matter because this is an outgoign connection). Is there anything im missing here?

	IPaddress ip;		/* Server address */
	TCPsocket sd;		/* Socket descriptor */
	int quit, len;
	char buffer[512];

	if (SDLNet_Init() < 0)
	{
		fprintf(stderr, "SDLNet_Init: %s\n", SDLNet_GetError());
		exit(EXIT_FAILURE);
	}

	if (SDLNet_ResolveHost(&ip, "Gamedev.net", 6038))
	{
		fprintf(stderr, "SDLNet_ResolveHost: %s\n", SDLNet_GetError());
		exit(EXIT_FAILURE);
	}
	if (!(sd = SDLNet_TCP_Open(&ip)))
	{
		fprintf(stderr, "SDLNet_TCP_Open: %s\n", SDLNet_GetError());//ALWAYS REPORTS CANNOT CONNECT TO REMOTE HOST
		exit(EXIT_FAILURE);
	}



thanks for any help, I'm pretty fed up with this
____________________________"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
Why do you believe that gamedev.net would be listening on port 6038?

Try connecting to host www.google.com on port 80 instead. There's quite likely someone listening there :-)
enum Bool { True, False, FileNotFound };
Advertisement
That worked, thanks alot =)

Problem now is trying to connect to myself (or router in this case). If I replace "gamedev.net" (now google) with my ip address (67.XXX.XXX.XXX) I can only connect through port 80 (the http port if i recall) how do i get the router to send the message to the right computer if i can only go through port 80.
____________________________"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
This is probably an issue with your firewall.... however, if you have to, IIRC you can set your game to use port 80 and it will work fine.

Try doing 127.0.0.1 instead of your IP. If this works then it's my bet that you have a firewall issue.
FTA, my 2D futuristic action MMORPG
Well for the above IP 127.0.0.1 I cant connect to it on port 80 or 6038, not quite sure which port u wanted me to use. anyway guess port 80 is the way to go, thanks =)
____________________________"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie
Is actually anything listening on those ports on your computer? To connect somewhere, that somewhere needs to actually be listening on that port.
enum Bool { True, False, FileNotFound };
Advertisement
Wait so in order to have a client socket you also need to be LISTENING on the socket as well?

Just making sure i got this right

EDIT: ok I think i miss-read your post, yes when I was connecting to the above ports 6038, I was listening on the other end. Ill try a couple other things though

EDIT: ok well i did some checking and it turns out that for some reason my computer wasn't registered in the DHCP client table when I checked it, I could still get on the internet though so dont ask me how that works, Anyway things work fine now. Thanks for all your help (so happy I got something to work)

[Edited by - raptorstrike on January 30, 2006 7:29:28 PM]
____________________________"This just in, 9 out of 10 americans agree that 1 out of 10 americans will disagree with the other 9"- Colin Mochrie

This topic is closed to new replies.

Advertisement