SDL_net only works with localhost!

I tried to write a very simple client-server test program (basically copy-pasting from reliable sources). I execute both the client and the server programs on my computer, and it all works nicely with both TCP and UDP, as long as i use “localhost” as the server hostname. If I try to put my actual IP address or hostname, it stops working. I tried to distribute my program, asking people for their IP and testing it, and it still doesn’t work.
For the record, I’m using SDL2 with the latest version of SDL_net, and everything is running on Windows 7. I did open the port that I’m using, for both TCP and UDP, and for both inward and outward communication.
What I do is basically just figure out my IP address (by googling “my IP”), and give the string as a parameter to the client’s SDLNet_ResolveHost call. Why is this wrong?

Bind to 0.0.0.0 and forward the port on your router to your LAN ip.On Fri, Nov 15, 2013 at 10:18 PM, MindFlyer wrote:

I tried to write a very simple client-server test program (basically
copy-pasting from reliable sources). I execute both the client and the
server programs on my computer, and it all works nicely with both TCP and
UDP, as long as i use “localhost” as the server hostname. If I try to put my
actual IP address or hostname, it stops working. I tried to distribute my
program, asking people for their IP and testing it, and it still doesn’t
work.
For the record, I’m using SDL2 with the latest version of SDL_net, and
everything is running on Windows 7. I did open the port that I’m using, for
both TCP and UDP, and for both inward and outward communication.
What I do is basically just figure out my IP address (by googling “my IP”),
and give the string as a parameter to the client’s SDLNet_ResolveHost call.
Why is this wrong?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

To answer your actual question as to why it is wrong (I assume) you
have a router which has a single internet IP and all clients in your
LAN are in their own network NATed under that single IP.On Fri, Nov 15, 2013 at 10:48 PM, Andre D <@Andre_D> wrote:

Bind to 0.0.0.0 and forward the port on your router to your LAN ip.

On Fri, Nov 15, 2013 at 10:18 PM, MindFlyer wrote:

I tried to write a very simple client-server test program (basically
copy-pasting from reliable sources). I execute both the client and the
server programs on my computer, and it all works nicely with both TCP and
UDP, as long as i use “localhost” as the server hostname. If I try to put my
actual IP address or hostname, it stops working. I tried to distribute my
program, asking people for their IP and testing it, and it still doesn’t
work.
For the record, I’m using SDL2 with the latest version of SDL_net, and
everything is running on Windows 7. I did open the port that I’m using, for
both TCP and UDP, and for both inward and outward communication.
What I do is basically just figure out my IP address (by googling “my IP”),
and give the string as a parameter to the client’s SDLNet_ResolveHost call.
Why is this wrong?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

In other words you need to bind to your LAN ip address…not your
internet IP. Unless your box is actually facing the net directly.On Fri, Nov 15, 2013 at 10:54 PM, Andre D <@Andre_D> wrote:

To answer your actual question as to why it is wrong (I assume) you
have a router which has a single internet IP and all clients in your
LAN are in their own network NATed under that single IP.

On Fri, Nov 15, 2013 at 10:48 PM, Andre D <@Andre_D> wrote:

Bind to 0.0.0.0 and forward the port on your router to your LAN ip.

On Fri, Nov 15, 2013 at 10:18 PM, MindFlyer wrote:

I tried to write a very simple client-server test program (basically
copy-pasting from reliable sources). I execute both the client and the
server programs on my computer, and it all works nicely with both TCP and
UDP, as long as i use “localhost” as the server hostname. If I try to put my
actual IP address or hostname, it stops working. I tried to distribute my
program, asking people for their IP and testing it, and it still doesn’t
work.
For the record, I’m using SDL2 with the latest version of SDL_net, and
everything is running on Windows 7. I did open the port that I’m using, for
both TCP and UDP, and for both inward and outward communication.
What I do is basically just figure out my IP address (by googling “my IP”),
and give the string as a parameter to the client’s SDLNet_ResolveHost call.
Why is this wrong?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

OMG Andre D, it worked!! Thank you very much!

Just two quick questions.

  1. You said “Bind to 0.0.0.0”. What does it mean? I merely added a forwarding rule to my router, saying that port 1234 has to be forwarded to 192.168.0.10, then in the client’s code I used my real IP, and that worked. I didn’t have to write 0.0.0.0 anywhere, so I’m kind of confused as to why you said that. Am I missing something?

  2. What if I want to distribute some clients to other people, and run the server on my computer? Do all the clients need to do that forwarding thing on their routers, or what I already did is sufficient?

Thanks again.

  1. 0.0.0.0 binds to all interfaces, in your case, localhost and your LAN ip

  2. Clients connect out to your server, only servers need to be facing
    the internet, not clients.On Fri, Nov 15, 2013 at 11:10 PM, MindFlyer wrote:

OMG Andre D, it worked!! Thank you very much!

Just two quick questions.

  1. You said “Bind to 0.0.0.0”. What does it mean? I merely added a
    forwarding rule to my router, saying that port 1234 has to be forwarded to
    192.168.0.10, then in the client’s code I used my real IP, and that worked.
    I didn’t have to write 0.0.0.0 anywhere, so I’m kind of confused as to why
    you said that. Am I missing something?

  2. What if I want to distribute some clients to other people, and run the
    server on my computer? Do all the clients need to do that forwarding thing
    on their routers, or what I already did is sufficient?

Thanks again.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Oh, and binding to your internet IP likely worked as your router was
smart and routed it back at you.On Fri, Nov 15, 2013 at 11:12 PM, Andre D <@Andre_D> wrote:

  1. 0.0.0.0 binds to all interfaces, in your case, localhost and your LAN ip

  2. Clients connect out to your server, only servers need to be facing
    the internet, not clients.

On Fri, Nov 15, 2013 at 11:10 PM, MindFlyer wrote:

OMG Andre D, it worked!! Thank you very much!

Just two quick questions.

  1. You said “Bind to 0.0.0.0”. What does it mean? I merely added a
    forwarding rule to my router, saying that port 1234 has to be forwarded to
    192.168.0.10, then in the client’s code I used my real IP, and that worked.
    I didn’t have to write 0.0.0.0 anywhere, so I’m kind of confused as to why
    you said that. Am I missing something?

  2. What if I want to distribute some clients to other people, and run the
    server on my computer? Do all the clients need to do that forwarding thing
    on their routers, or what I already did is sufficient?

Thanks again.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

(or something, seriously, bind to the LAN interface)On Fri, Nov 15, 2013 at 11:15 PM, Andre D <@Andre_D> wrote:

Oh, and binding to your internet IP likely worked as your router was
smart and routed it back at you.

On Fri, Nov 15, 2013 at 11:12 PM, Andre D <@Andre_D> wrote:

  1. 0.0.0.0 binds to all interfaces, in your case, localhost and your LAN ip

  2. Clients connect out to your server, only servers need to be facing
    the internet, not clients.

On Fri, Nov 15, 2013 at 11:10 PM, MindFlyer wrote:

OMG Andre D, it worked!! Thank you very much!

Just two quick questions.

  1. You said “Bind to 0.0.0.0”. What does it mean? I merely added a
    forwarding rule to my router, saying that port 1234 has to be forwarded to
    192.168.0.10, then in the client’s code I used my real IP, and that worked.
    I didn’t have to write 0.0.0.0 anywhere, so I’m kind of confused as to why
    you said that. Am I missing something?

  2. What if I want to distribute some clients to other people, and run the
    server on my computer? Do all the clients need to do that forwarding thing
    on their routers, or what I already did is sufficient?

Thanks again.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Andre D wrote:

  1. Clients connect out to your server, only servers need to be facing
    the internet, not clients.

Even if the protocol is UDP, and both client and server are sending and receiving packets?

Yes, the connection is a two way street.On Fri, Nov 15, 2013 at 11:16 PM, MindFlyer wrote:

Andre D wrote:

  1. Clients connect out to your server, only servers need to be facing
    the internet, not clients.

Even if the protocol is UDP, and both client and server are sending and
receiving packets?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I suggest you read into some of this stuff though, you appear to have
some…gapsOn Fri, Nov 15, 2013 at 11:17 PM, Andre D <@Andre_D> wrote:

Yes, the connection is a two way street.

On Fri, Nov 15, 2013 at 11:16 PM, MindFlyer wrote:

Andre D wrote:

  1. Clients connect out to your server, only servers need to be facing
    the internet, not clients.

Even if the protocol is UDP, and both client and server are sending and
receiving packets?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

fyi I reread what I said with “Oh, and binding to your internet IP likely
worked as your router was
smart and routed it back at you.”, it is not really at all correct and
pretty stupid. Ignore that bit.On Fri, Nov 15, 2013 at 11:17 PM, Andre D <@Andre_D> wrote:

I suggest you read into some of this stuff though, you appear to have
some…gaps

On Fri, Nov 15, 2013 at 11:17 PM, Andre D <@Andre_D> wrote:

Yes, the connection is a two way street.

On Fri, Nov 15, 2013 at 11:16 PM, MindFlyer wrote:

Andre D wrote:

  1. Clients connect out to your server, only servers need to be facing
    the internet, not clients.

Even if the protocol is UDP, and both client and server are sending and
receiving packets?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Andre D wrote:

I suggest you read into some of this stuff though, you appear to have some…gaps

Well, I’ve got a phd in computer science and I actually took some undergrad courses in network design and network programming, but I never actually did anything concrete until now. I’m only a theoretician.

You should do a search for 'beejs guide to network programming’On 15 Nov 2013 23:23, “MindFlyer” wrote:

Andre D wrote:

I suggest you read into some of this stuff though, you appear to have
some…gaps

Well, I’ve got a phd in computer science and I actually took some
undergrad courses in network design and network programming, but I never
actually did anything concrete until now. I’m only a theoretician.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org