1

What does bind to address 192.168.1.4 mean?

I have come to know that if an application bind to 0.0.0.0 then it means listen on all interface but it doesn't make much sense to me. Can someone explain bind address and what does binding to a particular ip address mean.

Also is it the network id or ip specific address that you use?

Thanks

0

1 Answer 1

7

This terminology comes from network programming:

A computer typically has one IP address for each network card. A computer may have multiple IP addresses for a network card (this is even the normal case when using IPv6). And a computer has the "localhost" address (127.0.0.1 when using IPv4).

This means that a computer has multiple IP addresses.

By "binding" a socket (or a similar operating-system object) to an address, you tell the operating system which of the addresses of a computer shall be used together with this socket:

Let's say a computer has two IP addresses: 192.168.1.4 and 192.168.2.9.

If you bind a socket for incoming TCP connections to 192.168.1.4, it cannot accept incoming TCP connections with a destination address of 192.168.2.9 but only connections to 192.168.1.4.

If you bind a socket to 0.0.0.0, it will accept data (such as TCP connections) for all IPv4 addresses of the computer the software is running on. (The same is true for the address 0::0 when using IPv6.)

1
  • Don't forget the logical loopback address that a host always has, even without a network interface. Binding to that enables local-only services.
    – Zac67
    Jun 15, 2019 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.