简体   繁体   English

客户端使用高端口号

[英]Client use high port number

Why does the client end of a connection use high port number(ephemeral ports) whereas the applications listen on typically small port numbers ? 为什么连接的客户端使用高端口号(临时端口),而应用程序通常监听小端口号?

Thx in advans, Karthik Balaguru Thx in advans,Karthik Balaguru

Servers listen on a fixed port number so that clients will know where to connect. 服务器侦听固定端口号,以便客户端知道连接的位置。 Clients do not need to use a fixed port number, since no one is initiating a connection to them, and in fact they cannot use a fixed port number if there may be more than one client running on the same machine (eg a web browser) connecting to the same server. 客户端不需要使用固定端口号,因为没有人启动与它们的连接,并且实际上如果在同一台机器上运行多个客户端(例如Web浏览器),则它们不能使用固定端口号连接到同一台服务器。 IANA has designated ports in the range 0..49151 as fixed port numbers for specific services, and ports in the range 49152..65535 as dynamic (ephemeral) ports which are not assigned to any service and can be used when a fixed port number is not required. IANA已将 0..49151范围内的端口指定为特定服务的固定端口号,将49152..65535范围内的端口指定为未分配给任何服务的动态(短暂)端口,并可在固定端口号时使用不需要。

The port range 0..49151 is further divided into the well known range 0..1023, which only a privileged process can bind to (at least on Unix/Linux), and the registered range 1024..49151. 端口范围0..49151进一步划分为众所周知的范围0..1023,只有特权进程可以绑定(至少在Unix / Linux上), 注册范围1024..49151。 Ports in the range 1024..49151 can be used by server processes that may run as an unprivlieged user, and it is also possible for clients to use ports in this range if they are not being used by a server (eg dynamic ports on Linux and Solaris start at 32768 by default, rather than 49152). 服务器进程可以使用1024..49151范围内的端口,这些服务器进程可以作为非特权用户运行,如果服务器没有使用它们,客户端也可以使用此范围内的端口(例如Linux上的动态端口) Solaris默认情况下从32768开始,而不是49152)。

Ports numbers under 1024 are called "registered", while those above (limit of 65,535) are called "unregistered". 1024以下的端口号称为“已注册”,而上述值(限制为65,535)称为“未注册”。 All these two terms mean is that ports under 1024 have standard services associated with them. 所有这两个术语的意思是1024以下的端口具有与之关联的标准服务。 IE: 53 for DNS, 80 for HTTP, 25 for SMTP, etc. Note they are associated - there is nothing to stop you from setting your application to use port 53, 25, etc but it's not recommended because other services will attempt to connect and or operate on these ports so it could cause problems. IE:53用于DNS,80用于HTTP,25用于SMTP等。注意它们是关联的 - 没有什么可以阻止您将应用程序设置为使用端口53,25等,但不建议这样做,因为其他服务将尝试连接或者在这些端口上运行,因此可能会导致问题。

The unregistered port region is dynamically used by client applications. 未注册的端口区域由客户端应用程序动态使用。 IE: You are reading this answer while connecting to port 80 of the StackOverflow.com webserver(s), but your browser is using an unregistered port to initiate that request. IE:您在连接到StackOverflow.com网络服务器的端口80时正在阅读此答案,但您的浏览器正在使用未注册的端口来启动该请求。

Because server ports are usually well known ports . 因为服务器端口通常是众所周知的端口 On a Unix box you will see their assignment in /etc/services file. 在Unix框中,您将在/etc/services文件中看到它们的分配。 The client ports, on the other hand, are usually picked by TCP/IP stack from the specific high range. 另一方面,客户端端口通常由特定高范围的TCP / IP堆栈挑选。 So servers know what ports to listen on, clients know what port to connect to, and nobody cares what port the connection is made from . 所以服务器知道哪些端口上侦听,客户知道连接到哪个端口,根本没人关心什么端口的连接制成

Lower port numbers (< 1024) are reserved to privileged processes. 较低的端口号(<1024)保留给特权进程。 In addition, many of these ports are assigned to specific services by the Internet Assigned Number Authority . 此外,许多这些端口由Internet Assigned Number Authority分配给特定服务。 Clients establish connections to servers listening on these well-known ports, but use dynamically assigned port numbers in the higher ranges according to the ports that are available to them. 客户端与侦听这些众所周知的端口的服务器建立连接,但根据可用的端口使用较高范围内的动态分配的端口号。

Lower port numbers are typically reserved for common applications. 较低的端口号通常保留用于常见应用程序。 Shorter = easier to remember. 更短=更容易记住。

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

相关问题 如何区分服务器端口号和客户端端口号? - how to make a difference between server port number and client port number? 客户端和服务器上相同连接的端口号不同 - Different port number on client and server for same connection 客户端中的DatagramSocket未绑定到服务器中的端口。 端口已在使用中 - DatagramSocket in Client not binding to the port in Server. Port already in use 我应该使用哪个端口号 - What port number should I use 从同一端口上的单个客户端到同一服务器的最大连接数 - max number of connection from single client to same server on same port 使用scapy高频发送UDP ping,为什么只收到前几条ICMP端口不可达消息? - use scapy to send UDP ping with a high frequency, why only receive the first few ICMP port unreachable message? 如何强制Web服务客户端使用特定端口? - How can you force a web service client to use a specific port? 我得到的端口号与我使用的端口号不同 - I am getting a different port number than I use 为什么UDP和TCP使用端口号而不使用PID来定位目标? - Why UDP and TCP use port number but not PID to locate the destination? 客户端程序如何将给定的知名服务转换为相应的端口号? - How can a client program convert a given well known service to a corresponding port number?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM