Opening ports

Started by
8 comments, last by Decrius 16 years, 2 months ago
I've written a chat app, however: if my PC is the server, the client cannot connect to it. It takes very long, like 10 seconds, and then it says (SDL_net): "Couldn't bind to local port". I've tried port 9999 and 11111, both not working. I've opened those ports on my router and redirect them to my PC in the LAN network. I even put off WinXP firewall...still no results. #1 Any thoughts on this one? #2 Does the client need to open the port on its router? Thanks, Decrius
[size="2"]SignatureShuffle: [size="2"]Random signature images on fora
Advertisement
Does it work if you run the server and client on the same machine? If so, are you sure the port is forwarded correctly on the router? Do you know if it's using UDP or TCP (SDL_net probably calls them reliable and unreliable)?

EDIT: If you're running both the client and server on the same LAN, the router probably has nothing to do with it. It usually only comes in if the client is WAN side and the server is LAN side.
127.0.0.1 works
192.168.1.101 (my LAN ip) works
But when I type our IP address it doesn't work.

I use the TCP protocol. I've tried http://www.canyouseeme.org/, and it says timed out...and for port 9999 it says refused.
[size="2"]SignatureShuffle: [size="2"]Random signature images on fora
Quote:Original post by Decrius
127.0.0.1 works
192.168.1.101 (my LAN ip) works
But when I type our IP address it doesn't work.

I use the TCP protocol. I've tried http://www.canyouseeme.org/, and it says timed out...and for port 9999 it says refused.
If the client and server are both on the LAN, then the external IP has nothing to do with it.

If the client is outside of the LAN, and the server is inside, then the port needs forwarded. If that website says the connection is refused, that indicates that the server wasn't running; usually routers will just cause the connection to time out if the port is blocked.
Okay thanks for your response :)

When I run the server and check for port 9999, it still says refused (canyouseeme.org) and still times out on 11111.

I thought: if I type my external IP while client and server is on the same PC, it would have to go through the router and would simulate a real external connection...however, this doesn't work so far.
[size="2"]SignatureShuffle: [size="2"]Random signature images on fora
Quote:Original post by Decrius
I thought: if I type my external IP while client and server is on the same PC, it would have to go through the router and would simulate a real external connection...however, this doesn't work so far.
I've never got that to work before. I'm sure there's a reason for it, but I don't know what it is. Presumably because the external IP address is only used for external connections, so the server can't reply. Or the router gets confused or something.

If you want to test an external connection, you're going to need an external PC.
Ah thanks :), will try that out xD
[size="2"]SignatureShuffle: [size="2"]Random signature images on fora
Looping a connection from a machine through the router back to the same machine works for me. Might be a difference in router model though. My guess though is that the OP hasn't set up the port-forwarding right. I remember I found it tricky when I first tried - even though I had opened the port the firewall settings denied incoming connections.
Router loopback is not reliably implemented in all routers, unfortunately. This means you'll have to use an external machine to test your port forwarding if you have a router that's broken like that.
enum Bool { True, False, FileNotFound };
Ok guys, call me stupid.

I used the ip either as ip address and as port (argv[1] while it should be argv[2])...=/

Anyways, thanks for your replies. I'm now rebuilding the whole script to make it more organised, than I found out that I used the ip as port, which I didn't open up on my router ofcourse...haven't tested it yet but I'm pretty sure it works now :)
[size="2"]SignatureShuffle: [size="2"]Random signature images on fora

This topic is closed to new replies.

Advertisement