Skip to content Skip to sidebar Skip to footer

Why Would I Bind On A Different Server Than 127.0.0.1?

I am starting to learn 'networking' with Python. I have followed a basic tutorial to run a Client/Server architecture with a TCP connection. I get the whole logic, but I don't unde

Solution 1:

You don't bind to a machine but to a network interface, so you want to bind to the interface that will receive the incoming packets. For example, 127.0.0.1 is the internal (loop) interface that is not reachable from anywhere outside the same machine, so you want to bind to a different interface as soon as you expect traffic from outside.

A host can have any number of network interfaces, for example by using multiple LAN adapters, using LAN and Wireless at the same time, or due to virtualisation. You may want to listen to a specific interface only, maybe in order to restrict accessibility to your wireless network but no other, or whatever reason you may have.

Binding to 0.0.0.0 will make your process listen to all available interfaces at the same time.

Solution 2:

You can bind to 192.168.1.5, or whatever your local IP address is so your server is reachable from the local network.

You can also bind to 104.31.82.58, or whatever your public IP is so anyone from all over the world could connect to your server.

I mean, you can't really bind to 104.31.82.58, you should bind to your own IP address.

Post a Comment for "Why Would I Bind On A Different Server Than 127.0.0.1?"