Unix套接字,SOCK_SEQPACKET和SOCK_DGRAM

前端之家收集整理的这篇文章主要介绍了Unix套接字,SOCK_SEQPACKET和SOCK_DGRAM前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
看来至少有3种不同的本地/ unix套接字类型(PF_UNIX),SOCK_STREAM,SOCK_DGRAM和SOCK_SEQPACKET。

虽然我知道SOCK_STREAM给你一个双向字节流,如TCP或双向管道,另外两个给你一个messge / packet API,SOCK_DGRAM和SOCK_SEQPACKET的unix套接字有什么区别?

因为这些只是本地的,我不能想到有人会以一种可以重新排序数据包的方式实现SOCK_DGRAM的好理由。

另外,SOCK_DGRAM / SOCK_SEQPACKET是否使用流控制,或者可以在缓慢读取器的情况下删除邮件

这里是一个关于SOCK_SEQPACKET的预期用例的好文章,事实上它在IP协议族中并不真正可用,以及如何使用现有的TCP语义获得同样的东西:

http://urchin.earth.li/~twic/Sequenced_Packets_Over_Ordinary_TCP.html

注意,SOCK_SEQPACKET在行为上比SOCK_DGRAM更接近SOCK_STREAM。

引用自引用的网站:

The SOCK_SEQPACKET socket type is similar to the SOCK_STREAM type,and is also connection-oriented. The only difference between these types is that record boundaries are maintained using the SOCK_SEQPACKET type. A record can be sent using one or more output operations and received using one or more input operations,but a single operation never transfers parts of more than one record. Record boundaries are visible to the receiver via the MSG_EOR flag in the received message flags returned by the recvmsg() function. It is protocol-specific whether a maximum record size is imposed.

原文链接:https://www.f2er.com/bash/389769.html

猜你在找的Bash相关文章