Difference between UNIX domain STREAM and DATAGRAM sockets?

前端 未结 4 406
一生所求
一生所求 2021-01-30 00:55

This question is NOT for the difference between STREAM type and DATAGRAM type INTERNET sockets. I know that STREAM sockets use TCP, Datagram sockets use UDP and all the T

4条回答
  •  孤独总比滥情好
    2021-01-30 01:21

    1. One likely difference are message boundaries. Datagrams will be delivered as a whole with the datagrams being the natural message boundaries. With stream sockets you can read N bytes and the socket will block until N bytes are ready. But this means no obvious message boundaries.

    2. All things being equal, if speed is a concern, instrument and measure. (I assume you already know that only a stream socket provides built-in reliable in-order transport, and only datagram sockets can be used to send to multiple receivers).

提交回复
热议问题