为什么不能在不同的服务器绑定到同一端口? [英] Why can't different servers bind to the same port?

查看:284
本文介绍了为什么不能在不同的服务器绑定到同一端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我感到困惑的端口。

我觉得很奇怪,我们需要给不同的服务器绑定到不同的端口。

I find it odd that we need to bind different servers to different ports.

例如:
Apache的绑定上8080,防爆press.js不能在8080绑定

Example: Apache binded on 8080, Express.js can't bind on 8080

如何服务器端口绑定的应用程序端口监听有什么不同?

How does server port binding differ from application port listening?

例如:
不同的浏览器,IE,铬,火狐,能倾听和沟通上的端口80?

Example: Different browsers, ie, chrome, firefox, can listening and communicated on port 80?

此问题试图运行:单位咕噜测试的时候走了过来。有一个已经绑定到8080 Tomcat服务器,但是服务器咕噜开始,中间件相信,能够启动,但它无法捕捉到浏览器。停止Tomcat服务器使事情的工作。

This issue came up when trying to run "grunt test:unit". There was a tomcat server that was already bound to 8080, but the server grunt starts, middleware I believe, is able to startup, but it is not able to to capture the browser. Stopping the tomcat server made things work.

推荐答案

其实,火狐,Chrome等使用不同的源端口。他们不听端口;他们连接到远程服务器。该服务器正在监听一个端口(80)上。从该浏览器连接被随机选择,并且是大量的源端口。您可以检查此使用的netstat 。他们的目标的端口是相同的(80)。

Actually, Firefox, Chrome, etc. use different source ports. They don't listen on ports; they connect to remote servers. The servers are listening on one port (80). The source port from which the browser connects is chosen randomly and is a high number. You can check this using netstat. Their destination port is the same (80).

为什么你不能有多个服务器绑定到同一端口*的原因是因为操作系统将不知道手该应用程序关闭传入连接。

The reason why you can't have multiple servers binding to the same port* is because the operating system wouldn't know which application to hand off an incoming connection to.

*其实,你可以,但它很复杂。 <一href=\"http://stackoverflow.com/questions/14388706/socket-options-so-reuseaddr-and-so-reuseport-how-do-they-differ-do-they-mean-t\">SO_REUSEPORT

*actually, you can, but it's complicated. SO_REUSEPORT

这篇关于为什么不能在不同的服务器绑定到同一端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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