Unix socket, SOCK_SEQPACKET vs SOCK_DGRAM

前端 未结 5 1978
一生所求
一生所求 2021-02-01 12:36

It seems there\'s atleast 3 different local/unix socket types (AF_UNIX) , SOCK_STREAM, SOCK_DGRAM and SOCK_SEQPACKET.

<
5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-01 13:06

    socket(2) linux-provided manpage: “DGRAM: datagrams (connectionless, unreliable messages), SEQPACKET: sequenced, reliable, [two-way] connection-based data transmission path for datagrams". Significant difference.

    unix(7) linux-provided manpage says: “SOCK_DGRAM, for a datagram-oriented socket that preserves message boundaries [but not necessarily order] [...] SOCK_SEQPACKET, for a connection-oriented socket that preserves message boundaries and delivers messages in the order that they were sent.”

    The standard permits that you get reordered packets with SOCK_DGRAM. (In other words, if an OS hands them to you in order, that is an implementation-specific feature. Or just pure timing luck.)

    There is flow control in the af_file/af_unix implementation in Linux, but that does not need to correlate with standard specified behavior at all.

提交回复
热议问题