网络示例代码应使用哪个端口号? [英] Which port number should be used for network example code?

查看:165
本文介绍了网络示例代码应使用哪个端口号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一个Haskell网络示例,但是我不知道我应该使用哪个端口.

I've written a little Haskell network example, but i don't know, which port i should use.

我在找到的IETF论文或 Wikipedia的端口号列表中找不到示例端口号,但是在编程社区中也许有一个通用的端口号.

i couldn't find a example port number in the IETF papers i found or in Wikipedia's list of port numbers, but maybe there is a common port number in the programming community.

推荐答案

端口的有效数字(与编程语言无关)为:0到2 ^ 16-1 = 0到65535
那是因为端口号是16位长.

Valid numbers for ports (regardless of the programming language) are: 0 to 2^16-1 = 0 to 65535
That is because a port number is 16 bit length.

但是端口分为:
知名端口:0到1023(用于系统服务,例如HTTP,FTP,SSH,DHCP等)
注册/用户端口:1024至49151(您可以在服务器上使用它,但请小心一些著名的应用程序:例如Microsoft SQL Server数据库管理系统(MSSQL)服务器或Apache Derby Network Server在此范围内,即不建议将MSSQL的端口分配给您的服务器,否则,如果MSSQL正在运行,则您的服务器很可能由于端口冲突而无法运行)
动态/专用端口:49152至65535.(不适用于服务器,例如NATing服务中的客户端)

However ports are divided into:
Well-known ports: 0 to 1023 (used for system services e.g. HTTP, FTP, SSH, DHCP ...)
Registered/user ports: 1024 to 49151 (you can use it for your server, but be careful some famous applications: like Microsoft SQL Server database management system (MSSQL) server or Apache Derby Network Server are already taking from this range i.e. it is not recommended to assign the port of MSSQL to your server otherwise if MSSQL is running then your server most probably will not run because of port conflict )
Dynamic/private ports: 49152 to 65535. (not used for the servers rather the clients e.g. in NATing service)

在编程中,您可以为服务器使用0到65535之间的任何数字,但是您应遵循上述范围,否则某些系统服务或某些应用程序将由于端口冲突而无法运行.
在此处检查大多数端口的列表: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

In programming you can use any numbers 0 to 65535 for your server, however you should stick to the ranges mentioned above, otherwise some system services or some applications will not run because of port conflict.
Check the list of most ports here: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

这篇关于网络示例代码应使用哪个端口号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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