tcp - 是否可以通过 TCP 发送数据报?

标签 tcp sockets datagram

理论上,没有什么可以阻止使用带有 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 一对一样式连接,这可能是您正在寻找的。

大多数 Unix/Linux 操作系统都有实现,Windows 也有第三方实现。有关详细信息,请参阅我链接的 Wiki 文章的末尾。

关于tcp - 是否可以通过 TCP 发送数据报?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2607696/

相关文章:

c# - 在c#和java套接字之间读写数据

C:如何创建套接字?

java - DatagramPacket 的 IP 字段何时从目的 IP 更改为源 IP?

qt4 - 使用 QUdpSocket 发送数据报

c# - 使用 TCP 发送和接收纯文本

postgresql - 如何使用 Zabbix 通过简单的无代理检查来配置数据库服务状态

java - 设置https ssl连接的客户端请求超时(相互认证)

c# - 如果没有发送数据,TCP 套接字会在一段时间后自动关闭吗?

Java : what is the difference between serversocket and datagramsocket?

c - 为什么 getsockopt() 没有返回 TCP_MAXSEG 的预期值?