是否可以通过 TCP 发送数据报? [英] Is it possible to send datagrams over TCP?
问题描述
理论上没有什么可以阻止使用带有 SOCK_DGRAM 的 TCP 套接字.您将获得可靠的数据报传输.这可以使用 Berkeley 套接字吗?
你想看的是SCTP 协议.它提供了通过可靠的 TCP 样式连接发送数据报的能力:
<块引用>与 TCP 相比,SCTP 可能是以记录为导向,这意味着它以以下方式传输数据消息,以类似的方式用户数据报协议 (UDP),以便在一个发送的一组字节(消息)传输操作(记录)是完全按照那个小组的意思阅读接收器应用程序.TCP是面向流,传输流字节,它正确地重新排序在无序交货的情况下.它然而,不尊重消息边界,即结构原始数据发送方的传输单元.
看看 SCTP 一对一风格的连接,这可能是您正在寻找的.p>
大多数 Unix/Linux 操作系统都有实现,Windows 有第三方实现.有关详细信息,请参阅我链接的 Wiki 文章的末尾.
In theory nothing prevents using TCP socket with SOCK_DGRAM. What you'll get is reliable datagram transport. Is this possible using Berkeley sockets?
What you want to take a look at is the SCTP Protocol. It provides the ability to send Datagrams over a reliable TCP style connection:
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.
Take a look at SCTP one to one style connections which are probably what you're looking for.
There are implementations for most Unix / Linux OS and there is a third party implementation for Windows. See the end of the Wiki article I linked for details.
这篇关于是否可以通过 TCP 发送数据报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!