IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QSctpServer Class

The QSctpServer class provides an SCTP-based server.

This class was introduced in Qt 5.8.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QSctpServer Class

  • Header: QSctpServer

  • Since: Qt 5.8

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS Network)

    target_link_libraries(mytarget PRIVATE Qt6::Network)

  • qmake: QT += network

  • Inherits: QTcpServer

  • Group: QSctpServer is part of Network Programming API

Detailed Description

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.

This class is not supported on the Windows platform.

See Also

Member Function Documentation

 

[explicit] 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

[virtual] QSctpServer::~QSctpServer()

Destroys the QSctpServer object. If the server is listening for connections, the socket is automatically closed.

See Also

See also close()

[override virtual protected] void QSctpServer::incomingConnection(qintptr socketDescriptor)

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

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.

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

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

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+