本文介绍了如何为自定义应用选择静态端口号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个自定义应用程序,需要在其自己的端口号上处理请求.我们确实不在乎数字是多少,尽管我们在决定后会坚持使用该端口.如何选择一个与用户系统上运行的其他应用程序或服务冲突最少的数字?

We've got a custom application that needs to serve requests on it's own port number. We really don't care what the number is, although we'll stick to that port after we decide. How do I select a number which is least likely to conflict with other applications or services that are running on the user's system?

我们应该遵守任何规则或标准吗?

Are there any rules or standards we should follow?

说明:选择端口后,我们必须坚持使用它.不能使用动态的.我们正在构建一个自定义SFTP服务器,我们必须告诉我们的客户它在哪个端口上运行.

A clarification: once we pick a port, we need to stick with it. Can't use a dynamic one. We're building a custom SFTP server and we'll have to tell our customers what port it's running on.

推荐答案

如果您无法预测您的应用程序将要运行的确切环境,请不要为此而烦恼.选择超过1024个的任何数字,并使其可配置,以便用户在与另一个服务/应用程序冲突的情况下进行更改.

If you can't predict the exact kind of environment your application is going to run, just don't bother with this. Pick any number over 1024 and also make it configurable so the user can change it in case of conflict with another service/application.

当然,您仍然可以避免使用非常常见的端口,例如8080(替代HTTP)或3128(代理(如squid),1666(perforce)等).您可以查看已知端口的完整列表此处,或查看/etc/services.

Of course you can still avoid very common ports like 8080 (alternative HTTP) or 3128 (proxies like squid), 1666 (perforce), etc. You can check a comprehensive list of known ports here, or take a look at /etc/services.

这篇关于如何为自定义应用选择静态端口号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 15:45