Unix套接字,SOCK_SEQPACKET VS SOCK_DGRAM [英] Unix socket, SOCK_SEQPACKET vs SOCK_DGRAM
问题描述
这似乎有ATLEAST 3个不同的地方/ Unix套接字类型(PF_UNIX),SOCK_STREAM,SOCK_DGRAM和SOCK_SEQPACKET。
It seems there's atleast 3 different local/unix socket types (PF_UNIX) , SOCK_STREAM, SOCK_DGRAM and SOCK_SEQPACKET.
虽然我知道,一个SOCK_STREAM给你一个双向字节流,如TCP或双向管道,和其他两个给你的messge /包API,什么是SOCK_DGRAM和SOCK_SEQPACKET的Unix套接字之间的区别?
While I know that a SOCK_STREAM gives you a bi-directional byte stream, like TCP or a bidirectional pipe, and the other two gives you a messge/packet API, what's the difference between a unix socket of SOCK_DGRAM and SOCK_SEQPACKET ?
由于这些仅是局部的,我想不出很好的理由有人可能重新排序的数据包的方式将实现SOCK_DGRAM一个的。
As these are local only, I can't think of a good reason someone would implement SOCK_DGRAM in a manner it could reorder packets.
此外,没有SOCK_DGRAM / SOCK_SEQPACKET聘请流量控制,也可以在邮件阅读速度慢的情况下,被丢弃?
Also, does SOCK_DGRAM/SOCK_SEQPACKET employ flow control, or can messages be dropped in case of slow readers ?
推荐答案
下面是 SOCK_SEQPACKET
的预期用途情况下的好文章,但事实上,它不是真正可用在IP协议族,以及如何可以得到同样的事情与现有的TCP语义:
Here is a good article on the intended use case for SOCK_SEQPACKET
, the fact that it's not really available in the IP protocol families, and how you can get the same thing with existing TCP semantics:
<一个href=\"http://urchin.earth.li/~twic/Sequenced_Packets_Over_Ordinary_TCP.html\">http://urchin.earth.li/~twic/Sequenced_Packets_Over_Ordinary_TCP.html
注意 SOCK_SEQPACKET
是行为 SOCK_STREAM
比 SOCK_DGRAM 更接近code>。
从引用的网站举例:
该SOCK_SEQPACKET套接字类型类似于SOCK_STREAM类型,也是面向连接的。这些之间的唯一区别
类型是记录边界正在使用维护
SOCK_SEQPACKET类型。 A记录可以使用一个或多个输出被发送
操作和接收使用一个或多个输入操作,但一个
单人操作从未传输多个记录的一部分。记录
通过边界在该MSG_EOR标志是接收机可见
收到邮件标志由recvmsg()函数返回。它是
协议特定的最大记录大小是否被强加的。
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.
这篇关于Unix套接字,SOCK_SEQPACKET VS SOCK_DGRAM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!