请选择 进入手机版 | 继续访问电脑版
hot【项目分享】之智能交通灯

结合前几次GPIO的简单了解和学习,今天给大家分享一个GPIO的简单应用:智能交通灯 涉及硬件:开发套件 详细

开启左侧

[原创] QSctpSocket Class

[复制链接]
HN飞花似梦 发表于 2017-5-9 15:54:26 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
QSctpSocket Class
The QSctpSocket class provides an SCTP socket. More...

Header:#include <QSctpSocket>qmakeT += networkSincet 5.8InheritsTcpSocket
The QSctpSocket class provides an SCTP socket.
SCTP (Stream Control Transmission Protocol) is a transport layer protocol serving in a similar role as the popular protocols TCP and UDP. Like UDP, SCTP is message-oriented, but it ensures reliable, in-sequence transport of messages with congestion control like TCP.
SCTP is connection-oriented protocol, which provides the complete simultaneous transmission of multiple data streams between endpoints. This multi-streaming allows data to be delivered by independent channels, so that if there is data loss in one stream, delivery will not be affected for the other streams.
Being message-oriented, SCTP transports a sequence of messages, rather than transporting an unbroken stream of bytes as does TCP. Like in UDP, in SCTP a sender sends a message in one operation, and that exact message is passed to the receiving application process in one operation. But unlike UDP, the delivery is guaranteed.
It also supports multi-homing, meaning that a connected endpoint can have alternate IP addresses associated with it in order to route around network failure or changing conditions.
QSctpSocket is a convenience subclass of QTcpSocket that allows you to emulate TCP data stream over SCTP or establish an SCTP connection for reliable datagram service.
QSctpSocket can operate in one of two possible modes:
Continuous byte stream (TCP emulation).
Multi-streamed datagram mode.
To set a continuous byte stream mode, instantiate QSctpSocket and call setMaximumChannelCount() with a negative value. This gives the ability to use QSctpSocket as a regular buffered QTcpSocket. You can call connectToHost() to initiate connection with endpoint, write() to transmit and read() to receive data from the peer, but you cannot distinguish message boundaries.
By default, QSctpSocket operates in datagram mode. Before connecting, call setMaximumChannelCount() to set the maximum number of channels that the application is prepared to support. This number is a parameter negotiated with the remote endpoint and its value can be bounded by the operating system. The default value of 0 indicates to use the peer's value. If both endpoints have default values, then number of connection channels is system-dependent. After establishing a connection, you can fetch the actual number of channels by calling readChannelCount() and writeChannelCount().
QSctpSocket类提供了一个SCTP套接字。
SCTP(流控制传输协议)是与流行协议TCP和UDP类似的传输层协议。像UDP一样,SCTP是面向消息的,但是它确保了具有TCP拥塞控制的消息的可靠的按顺序传输。
SCTP是面向连接的协议,它提供端点之间的多个数据流的完全同时传输。这种多流式传输允许通过独立信道传送数据,以便如果在一个流中存在数据丢失,传送将不会影响其他数据流。
作为面向消息的,SCTP传输一系列消息,而不是像TCP一样传输一串不间断的字节流。像UDP一样,在SCTP中,发送方在一个操作中发送消息,并且在一个操作中将该确切消息传递给接收应用进程。但是与UDP不同,交付是保证的。
它还支持多归属,这意味着连接的端点可以具有与其相关联的备用IP地址,以绕过网络故障或改变条件。
QSctpSocket是QTcpSocket的一个方便的子类,允许您通过SCTP模拟TCP数据流或建立可靠数据报服务的SCTP连接。
QSctpSocket可以以两种可能的模式之一运行:
连续字节流(TCP仿真)。
多流数据报模式。
要设置连续字节流模式,请实例化QSctpSocket并使用负值调用setMaximumChannelCount()。这样可以使用QSctpSocket作为常规缓冲QTcpSocket。您可以调用connectToHost()来启动与端点的连接,write()发送和读取()以从对等体接收数据,但不能区分消息边界。
默认情况下,QSctpSocket以数据报模式运行。在连接之前,调用setMaximumChannelCount()设置应用程序准备支持的最大通道数。该数字是与远程端点协商的参数,其值可以由操作系统限制。默认值为0表示使用对等体的值。如果两个端点都有默认值,则连接通道的数量与系统相关。建立连接后,您可以通过调用readChannelCount()和writeChannelCount()获取实际的通道数。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

发布主题
阅读排行 更多
广告位
0351-8210788
周一至周日 9:00-18:00
意见反馈:mind@unigress.com
关注我们

扫一扫关注我们

Powered by Discuz! X3.4 Licensed  © 2001-2013 Comsenz Inc.( 晋ICP备12005011 )