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

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

问题描述

如果我理解正确,应用程序有时会使用HTTP发送消息,因为使用其他端口可能会导致防火墙问题。但是,如果不与其他应用程序(如Web浏览器)冲突,它的工作原理如何?事实上,多个浏览器一次运行怎么不冲突?他们都监控端口并得到通知......你能以这种方式共享端口吗?

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 / HTTP 443 / 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 the web server receives the answer, it sends a response that has 80 as source port and 33123 as destination port.

因此,如果你有两个浏览器同时访问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天全站免登陆