TCP/UDP 解复用的工作原理是什么? [英] How TCP/UDP demultiplexing works?

查看:25
本文介绍了TCP/UDP 解复用的工作原理是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下声明.

"在 TCP 中,接收方主机使用所有源 IP、源端口、目的 IP 和目的端口将数据报定向到适当的套接字.而在 UDP 中,接收方仅检查目的端口号来定向数据报."

"In TCP, the receiver host uses all of source IP, source port, destination IP and destination port to direct datagram to appropriate socket. While in UDP, the receiver only checks destination port number to direct the datagram. "

以上说法是真的吗?

如果是,是否意味着在 TCP 中同一个端口可以在一个进程中用于多个套接字,而在 UDP 中,在一个进程中的一个端口上只能使用一个套接字?不同进程中的套接字呢?多个进程可以在 TCP/UDP 中使用同一个端口吗?(编程语言:C/C++/Java)

If yes, does it mean that in TCP the same port can be used for multiple socket in one process, while in UDP only one socket can use on a port in one process? What about sockets in different processes? Can multiple processes use the same port in TCP/UDP? (in programming language: C/C++/Java)

如果不是,为什么?

推荐答案

"在 TCP 中,接收方主机使用所有源 IP、源端口、目的 IP 和目的端口将数据报定向到适当的套接字.而在 UDP 中,接收方仅检查目的端口号来定向数据报."

"In TCP, the receiver host uses all of source IP, source port, destination IP and destination port to direct datagram to appropriate socket. While in UDP, the receiver only checks destination port number to direct the datagram. "

以上说法属实吗?

是的.

如果是,是不是意味着在TCP中同一个端口可以在一个进程中用于多个socket,

If yes, does it mean that in TCP the same port can be used for multiple socket in one process,

是的,在某些情况下.

而在 UDP 中,一个进程中的一个端口只能使用一个套接字?

while in UDP only one socket can use on a port in one process?

不,见下文.

不同进程中的套接字呢?多个进程可以在 TCP/UDP 中使用同一个端口吗?(编程语言:C/C++/Java)

What about sockets in different processes? Can multiple processes use the same port in TCP/UDP? (in programming language: C/C++/Java)

在某些情况下,是的.UDP 端口必须被所有想要共享它的进程指定为可重用.一个 TCP 端口只能被绑定到不同接口的套接字重用:没有共享.

Under some circumstances, yes. A UDP port has to be designated as reusable by all processes that want to share it. A TCP port can only be reused by sockets bound to different interfaces: there is no sharing.

这篇关于TCP/UDP 解复用的工作原理是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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