Can two applications listen to the same port?

前端 未结 17 1168
天涯浪人
天涯浪人 2020-11-22 03:50

Can two applications on the same machine bind to the same port and IP address? Taking it a step further, can one app listen to requests coming from a certain IP and the othe

17条回答
  •  难免孤独
    2020-11-22 04:28

    You can have one application listening on one port for one network interface. Therefore you could have:

    1. httpd listening on remotely accessible interface, e.g. 192.168.1.1:80
    2. another daemon listening on 127.0.0.1:80

    Sample use case could be to use httpd as a load balancer or a proxy.

提交回复
热议问题