how can an application use port 80/HTTP without conflicting with browsers?

前端 未结 7 1342
执笔经年
执笔经年 2020-12-02 05:27

If I understand right, applications sometimes use HTTP to send messages, since using other ports is liable to cause firewall problems. But how does that work without conflic

7条回答
  •  一个人的身影
    2020-12-02 06:09

    There are 2 ports: a source port (browser) and a destination port (server). The browser asks the OS for an available source port (let's say it receives 33123) then makes a socket connection to the destination port (usually 80/HTTP, 443/HTTPS).

    When the web server receives the answer, it sends a response that has 80 as source port and 33123 as destination port.

    So if you have 2 browsers concurrently accessing stackoverflow.com, you'd have something like this:

    Firefox (localhost:33123) <-----------> stackoverflow.com (69.59.196.211:80)
    Chrome  (localhost:33124) <-----------> stackoverflow.com (69.59.196.211:80)
    

提交回复
热议问题