QSctpServer Class
The QSctpServer class provides an SCTP-based server. More...
Header: | #include <QSctpServer> |
qmake: | QT += network |
Since: | Qt 5.8 |
Inherits: | QTcpServer |
Public Functions
QSctpServer(QObject *parent = nullptr) | |
virtual | ~QSctpServer() |
int | maximumChannelCount() const |
QSctpSocket * | nextPendingDatagramConnection() |
void | setMaximumChannelCount(int count) |
- 18 public functions inherited from QTcpServer
- 31 public functions inherited from QObject
Reimplemented Protected Functions
virtual void | incomingConnection(qintptr socketDescriptor) |
- 2 protected functions inherited from QTcpServer
- 9 protected functions inherited from QObject
Additional Inherited Members
- 1 property inherited from QObject
- 1 public slot inherited from QObject
- 2 signals inherited from QTcpServer
- 2 signals inherited from QObject
- 11 static public members inherited from QObject
- 2 protected functions inherited from QTcpServer
- 9 protected functions inherited from QObject
Detailed Description
The QSctpServer class provides an SCTP-based server.
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. See the QSctpSocket documentation for more protocol details.
QSctpServer is a convenience subclass of QTcpServer that allows you to accept incoming SCTP socket connections either in TCP emulation or in datagram mode.
The most common way to use QSctpServer is to construct an object and set the maximum number of channels that the server is prepared to support, by calling setMaximumChannelCount(). You can set the TCP emulation mode by passing a negative argument in this call. Also, a special value of 0 (the default) indicates to use the peer's value as the actual number of channels. The new incoming connection inherits this number from the server socket descriptor and adjusts it according to the remote endpoint settings.
In TCP emulation mode, accepted clients use a single continuous byte stream for data transmission, and QSctpServer acts like a plain QTcpServer. Call nextPendingConnection() to accept the pending connection as a connected QTcpSocket. The function returns a pointer to a QTcpSocket in QAbstractSocket::ConnectedState that you can use for communicating with the client. This mode gives access only to basic SCTP protocol features. The socket transmits SCTP packets over IP at system level and interacts through the QTcpSocket interface with the application.
In contrast, datagram mode is message-oriented and provides a complete simultaneous transmission of multiple data streams between endpoints. Call nextPendingDatagramConnection() to accept the pending datagram-mode connection as a connected QSctpSocket.
Note: This feature is not supported on the Windows platform.
See also QTcpServer, QSctpSocket, and QAbstractSocket.
Member Function Documentation
QSctpServer::QSctpServer(QObject *parent = nullptr)
Constructs a QSctpServer object.
Sets the datagram operation mode. The parent argument is passed to QObject's constructor.
See also setMaximumChannelCount(), listen(), and setSocketDescriptor().
[virtual]
QSctpServer::~QSctpServer()
Destroys the QSctpServer object. If the server is listening for connections, the socket is automatically closed.
See also close().
[virtual protected]
void QSctpServer::incomingConnection(qintptr socketDescriptor)
Reimplemented from QTcpServer::incomingConnection().
int QSctpServer::maximumChannelCount() const
Returns the maximum number of channels that the accepted sockets are able to support.
A value of 0 (the default) means that the number of connection channels would be set by the remote endpoint.
Returns -1, if QSctpServer running in TCP emulation mode.
See also setMaximumChannelCount().
QSctpSocket *QSctpServer::nextPendingDatagramConnection()
Returns the next pending datagram-mode connection as a connected QSctpSocket object.
Datagram-mode connection provides a message-oriented, multi-stream communication.
The socket is created as a child of the server, which means that it is automatically deleted when the QSctpServer object is destroyed. It is still a good idea to delete the object explicitly when you are done with it, to avoid wasting memory.
This function returns null if there are no pending datagram-mode connections.
Note: The returned QSctpSocket object cannot be used from another thread. If you want to use an incoming connection from another thread, you need to override incomingConnection().
See also hasPendingConnections(), nextPendingConnection(), and QSctpSocket.
void QSctpServer::setMaximumChannelCount(int count)
Sets the maximum number of channels that the server is prepared to support in datagram mode, to count. If count is 0, endpoint maximum number of channels value would be used. Negative count sets a TCP emulation mode.
Call this method only when QSctpServer is in UnconnectedState.
See also maximumChannelCount() and QSctpSocket.
© 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.