localhost vs real ip address

后端 未结 4 1302
栀梦
栀梦 2020-12-05 07:47

What is the difference between the localhost and the real ip address?

If I access an application by using http://localhost:8080/index.html and ht

4条回答
  •  情书的邮戳
    2020-12-05 08:23

    The difference is when you set up a listening socket (waiting for a connection) you have to tell it which address to bind to. The same applies for website configuration with all of the common web servers.

    Normally you will just bind to any address, which means you can access it via 127.0.0.1 or 192.x.x.x or whatever other IP addresses the machine happens to have, but occasionally you may want to bind to a specific one - e.g. if you have 4 public IPs on one machine you may want to have a specific site on a specific IP.

提交回复
热议问题