TCP/UDP多路分解如何工作? [英] How TCP/UDP demultiplexing works?

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

问题描述

我有以下声明.

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

以上说法正确吗?

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

如果没有,为什么?

解决方案

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

以上说法正确吗?

是的

如果是,是否表示在TCP中同一端口可在一个进程中用于多个套接字,

是的,在某些情况下.

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

不,请参见下文.

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

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

I have the following statement.

"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. "

Is the above statement true?

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)

If not, why?

解决方案

"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. "

Is the above statement true?

Yes.

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

Yes, under some circumstances.

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

No, see below.

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

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天全站免登陆