简体   繁体   English

开发人员工作流程:开发期间使用哪个端口是否重要?

[英]Developer workflow: Does it matter which port is used during development?

Are there any differences between choosing this or that port? 选择此端口或该端口有什么区别? Are there any standards for picking a port? 选港口有什么标准吗?

I'm just looking for the "why" a particular port was picked to be used. 我只是在寻找为什么选择使用特定端口的“原因”。 There doesn't appear to be a standard convention for picking a port number(at least in documentation). 似乎没有一个选择端口号的标准约定(至少在文档中如此)。

The examples in official docs use different port numbers. 官方文档中的示例使用不同的端口号。

  • Create React App docs provide examples using localhost:3000/ 创建React App文档提供使用localhost:3000 /的示例
  • Django docs provide examples using port 8000/ Django文档提供了使用端口8000 /的示例
  • Ember docs provide examples using port 4200/ Ember文档提供了使用端口4200 /的示例
  • Express docs provide examples using port 3000/ Express文档提供了使用端口3000 /的示例
  • Flask docs provide examples using port 5000/ Flask文档提供了使用端口5000 /的示例
  • Webpack docs provide examples using port 8080/ Webpack文档提供使用端口8080 /的示例

as you already realized: It doesn't really matter. 正如您已经意识到的:并不重要。 It should be over 1024, and maybe don't use an official port number. 它应该超过1024,并且可能不使用官方端口号。 Also its not bad that different systems use different number as default, so they don't clash. 同样,不同的系统使用不同的数字作为默认值也很不错,因此它们不会冲突。

This means you can run an express example and an ember server side by side with the default port number. 这意味着您可以使用默认端口号并排运行一个示例程序和一个ember服务器。

Btw I'm pretty sure embers 4200 is a reference to the hitchhiker's guide to the galaxy . 顺便说一句,我敢肯定,余烬4200是对搭便车者指南的参考。

3000 8000 and 8080 are typical dev ports. 3000 8000和8080是典型的开发人员端口。 However, I would pick something obscure (but meaningful to you) to avoid port conflicts. 但是,我会选择一些晦涩的(但对您有意义)以避免端口冲突。 I came up with a port number scheme where I would always start with 5 and then the other letters would be picked as follows: 我想出了一个端口号方案,该方案总是以5开头,然后按以下方式选择其他字母:

5
E - 5
M - 13 (minus 10) = 3
A - 1
I - 9
L

So my port for my EMAIL server would be 55319. Crazy? 因此,我的EMAIL服务器的端口为55319。疯狂吗? Not sure, but it meant I could work out the port and never ever got a conflict. 不确定,但这意味着我可以计算出端口,并且永远不会发生冲突。 Also, hackers often scan for open ports but it takes too long to scan all ports so they just scan frequently used ports. 另外,黑客经常扫描开放的端口,但是扫描所有端口的时间太长,因此他们只扫描频繁使用的端口。 So if you pick an obscure port then they won't scan it and will never know it is open! 因此,如果您选择了一个晦涩的端口,那么他们将不会对其进行扫描,并且永远不会知道它是开放的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM