关于TCP/IP端口绑定的问题
我想知道服务器应用程序是否总是在同一端口上应答?我在某处读到,为了继续监听“监听”端口,服务器将使用不同的端口。有人可以向我提供更多详细信息吗? 谢谢!
I would like to know whether a server application will always answer on the same port? I have read somewhere that in order to keep listening on the "listening" port, the server will use different port. Could anybody provide me with more details?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在特定端口上与服务器建立 TCP 连接,则该 TCP 连接将继续使用服务器端的同一端口。
TCP 连接是在一侧的
(address1, port1)
对和另一侧的(address2, port2)
对之间建立的 - 所有这四个值都是在 TCP 连接的生命周期内固定。这不会阻止服务器在接受连接后侦听端口 - 因为它可以根据
(地址,端口)
区分已建立连接和新连接的任何数据包客户端使用的对。例如,Oracle 服务器的这个
netstat
输出显示它正在侦听端口 1521,并且几个已建立的连接也使用该端口:If you make a TCP connection to a server on a particular port, that TCP connection will continue to use the same port on the server side.
A TCP connection is established between an
(address1, port1)
pair on one side and an(address2, port2)
pair on the other side - and all four of these values are fixed over the life of the TCP connection.This does not stop the server from listening on the port after it has accepted a connection - because it can differentiate between any packets for the established connection(s) and new connections based on the
(address, port)
pair used by the client.For example, this
netstat
output from an Oracle server shows it listening on port 1521, and several established connections also using that port:作为 TCP 握手过程的一部分,在另一个端口上建立通信通道。源和目标“端口”号对应于 TCP 数据包标头中的 16 位字段。一旦建立通道,通信就会在该端口上进行,并在标头字段中包含适当的源端口和目标端口值。
初始连接到服务器上的监听端口;此后,该进程在分配的新端口上建立 TCP 连接,并在这些端口上进行进一步的通信。
As a part of the TCP handshaking process, a communication channel is established on another port. The source and destination 'port' numbers correspond to 16 bit fields in the TCP packet header. Once the channel is established, the communication takes place on that port, with the appropriate source and destination port values in the fields on the header.
The initial connection is made to the listening port on the server; after this, the process establishes a TCP connection on the new ports assigned and further communication takes place on those ports.