UDP 套接字如何处理差异主机
How UDP Socket handle the diff host
假设主机C中的一个进程有一个端口号为6789的UDP套接字。假设
主机 A 和主机 B 都向主机 C 发送一个带有目的地的 UDP 报文段
端口号 6789。这两个段是否都指向同一个端口?
主机 C 上的套接字?如果是这样,主机 C 上的进程如何知道这两个
段来自两个不同的主机?
书上给出的解决方法如下
Yes, both segments will be directed to the same socket. For each
received segment, at the socket interface, the operating system will
provide the process with the IP addresses to determine the origins of
the individual segments.
我没有得到解决方案谁能详细说明一下?
如果把“UDP”换成“TCP”,答案是什么?
Will both of these segments be directed to the same socket at Host C?
如果主机C上的套接字没有显式连接,那么来自主机A的数据包和来自主机B的数据包都会到达这个套接字。
If so, how will the process at Host C know that these two segments originated from two different hosts?
使用recvfrom,客户端不仅可以获取数据包有效负载,还可以获取数据包的发送方。
What can be the answer if the word "UDP" is changed by "TCP" ?
TCP有连接的概念,包括连接的显式创建、数据传输和连接的显式断开。 A 和 B 每个人都必须先创建到 C 的连接,然后才能传输数据。为了使这成为可能,C 必须首先 listen on the bound server socket and then can accept a new connection. accept
will return a new socket which is used for the data transfer. It will also return the clients source IP and port (i.e. A or B) so that C knows which client is associated with the new connection. This can also be later checked on the accepted socket with getpeername.
假设主机C中的一个进程有一个端口号为6789的UDP套接字。假设 主机 A 和主机 B 都向主机 C 发送一个带有目的地的 UDP 报文段 端口号 6789。这两个段是否都指向同一个端口? 主机 C 上的套接字?如果是这样,主机 C 上的进程如何知道这两个 段来自两个不同的主机?
书上给出的解决方法如下
Yes, both segments will be directed to the same socket. For each received segment, at the socket interface, the operating system will provide the process with the IP addresses to determine the origins of the individual segments.
我没有得到解决方案谁能详细说明一下?
如果把“UDP”换成“TCP”,答案是什么?
Will both of these segments be directed to the same socket at Host C?
如果主机C上的套接字没有显式连接,那么来自主机A的数据包和来自主机B的数据包都会到达这个套接字。
If so, how will the process at Host C know that these two segments originated from two different hosts?
使用recvfrom,客户端不仅可以获取数据包有效负载,还可以获取数据包的发送方。
What can be the answer if the word "UDP" is changed by "TCP" ?
TCP有连接的概念,包括连接的显式创建、数据传输和连接的显式断开。 A 和 B 每个人都必须先创建到 C 的连接,然后才能传输数据。为了使这成为可能,C 必须首先 listen on the bound server socket and then can accept a new connection. accept
will return a new socket which is used for the data transfer. It will also return the clients source IP and port (i.e. A or B) so that C knows which client is associated with the new connection. This can also be later checked on the accepted socket with getpeername.