应用程序如何在不与浏览器冲突的情况下使用端口 80/HTTP? [英] how can an application use port 80/HTTP without conflicting with browsers?

查看:28
本文介绍了应用程序如何在不与浏览器冲突的情况下使用端口 80/HTTP?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我理解正确,应用程序有时会使用 HTTP 发送消息,因为使用其他端口可能会导致防火墙问题.但是如何在不与其他应用程序(如网络浏览器)发生冲突的情况下工作?事实上,同时运行的多个浏览器如何不冲突?他们是否都监控端口并得到通知...您可以通过这种方式共享端口吗?

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 conflicting with other applications such as web-browsers? In fact how do multiple browsers running at once not conflict? Do they all monitor the port and get notified... can you share a port in this way?

我觉得这是一个愚蠢的问题,但我以前从未想过,在其他情况下,当 2 个应用程序被配置为使用相同的端口时,我遇到了问题.

I have a feeling this is a dumb question, but not something I ever thought of before, and in other cases I've seen problems when 2 apps are configured to use the same port.

推荐答案

有 2 个端口:一个源端口(浏览器)和一个目标端口(服务器).浏览器向操作系统询问可用的源端口(假设它收到 33123),然后建立到目标端口的套接字连接(通常是 80/HTTP443/HTTPS).

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).

当 Web 服务器收到应答时,它会发送一个响应,其中源端口为 80,目的端口为 33123.

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

因此,如果您有 2 个浏览器同时访问 stackoverflow.com,您会看到如下内容:

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)

这篇关于应用程序如何在不与浏览器冲突的情况下使用端口 80/HTTP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆