非IANA批准的应用应使用哪些端口 [英] Which ports should be used for non-IANA approved applications

查看:92
本文介绍了非IANA批准的应用应使用哪些端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于非IANA批准的应用程序的开发人员来说,哪个端口范围最合适-1024+或49152+?乍看之下,似乎49152-65535更好,但OS还是将其用于临时端口.

Which range of ports is the best for developers of non-IANA approved applications -- 1024+ or 49152+? At first glance it seems that 49152-65535 is better but it's used by OS for ephemeral ports anyway.

推荐答案

要将端口用作服务器,您需要显式绑定到该端口.但是客户端套接字(即源自此主机的连接)也需要具有端口,除非明确设置了端口,否则它们将从临时端口范围中选择一个.

To use a port as a server you need to bind explicitly to this port. But client sockets (i.e. connections originating at this host) also need to have ports and unless they have a port explicitly set they pick one from the range of ephemeral ports.

这意味着,如果要为服务器套接字使用特定的临时端口号,则可能是某些客户端套接字已绑定到该端口.因此,最好将非临时端口用于服务器套接字.

This means that if you want to use a specific ephemeral port number for a server socket it might be that some client socket is already bound to it. Thus it is better to use a non-ephemeral port for server sockets.

这篇关于非IANA批准的应用应使用哪些端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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