理论上,没有什么可以阻止使用带有 SOCK_DGRAM 的 TCP 套接字。您将获得可靠的数据报传输。这可能使用 Berkeley 套接字吗?
最佳答案
你要看的是SCTP Protocol .它提供了通过可靠的 TCP 样式连接发送数据报的能力:
In contrast to TCP, SCTP may be characterized as record-oriented, meaning it transports data in terms of messages, in a similar fashion to the User Datagram Protocol (UDP), so that a group of bytes (message) sent in one transmission operation (record) is read exactly as that group at the receiver application. TCP is stream-oriented, transporting streams of bytes, which it correctly reorders in case of out-of-order delivery. It does not, however, honor message boundaries, i.e., the structure of data in terms of their original transmission units at the sender.
查看 SCTP 一对一样式连接,这可能是您正在寻找的。p>
大多数 Unix/Linux 操作系统都有实现,Windows 也有第三方实现。有关详细信息,请参阅我链接的 Wiki 文章的末尾。
关于tcp - 是否可以通过 TCP 发送数据报?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2607696/