Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsctpserver.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com>
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4//#define QSCTPSERVER_DEBUG
5
54#include "qsctpserver.h"
55#include "qsctpserver_p.h"
56
57#include "qsctpsocket.h"
59
60#ifdef QSCTPSERVER_DEBUG
61#include <qdebug.h>
62#endif
63
65
69 : maximumChannelCount(0)
70{
71}
72
78
88
98 : QTcpServer(QAbstractSocket::SctpSocket, *new QSctpServerPrivate, parent)
99{
100#if defined(QSCTPSERVER_DEBUG)
101 qDebug("QSctpServer::QSctpServer()");
102#endif
103}
104
112{
113#if defined(QSCTPSERVER_DEBUG)
114 qDebug("QSctpServer::~QSctpServer()");
115#endif
116}
117
129{
130 Q_D(QSctpServer);
131 if (d->state != QAbstractSocket::UnconnectedState) {
132 qWarning("QSctpServer::setMaximumChannelCount() is only allowed in UnconnectedState");
133 return;
134 }
135#if defined(QSCTPSERVER_DEBUG)
136 qDebug("QSctpServer::setMaximumChannelCount(%i)", count);
137#endif
138 d->maximumChannelCount = count;
139}
140
153{
154 return d_func()->maximumChannelCount;
155}
156
160{
161#if defined (QSCTPSERVER_DEBUG)
162 qDebug("QSctpServer::incomingConnection(%i)", socketDescriptor);
163#endif
164
165 QSctpSocket *socket = new QSctpSocket(this);
166 socket->setMaximumChannelCount(d_func()->maximumChannelCount);
169}
170
193{
194 Q_D(QSctpServer);
195
196 for (auto it = d->pendingConnections.begin(), end = d->pendingConnections.end(); it != end; ++it) {
197 QSctpSocket *socket = qobject_cast<QSctpSocket *>(*it);
199
200 if (socket->isInDatagramMode()) {
201 d->pendingConnections.erase(it);
202 Q_ASSERT(d->socketEngine);
203 d->socketEngine->setReadNotificationEnabled(true);
204 return socket;
205 }
206 }
207
208 return nullptr;
209}
210
212
213#include "moc_qsctpserver.cpp"
virtual bool setOption(SocketOption option, int value)=0
The QAbstractSocket class provides the base functionality common to all socket types.
virtual bool setSocketDescriptor(qintptr socketDescriptor, SocketState state=ConnectedState, OpenMode openMode=ReadWrite)
Initializes QAbstractSocket with the native socket descriptor socketDescriptor.
\inmodule QtCore
Definition qobject.h:103
virtual ~QSctpServerPrivate()
void configureCreatedSocket() override
The QSctpServer class provides an SCTP-based server.
Definition qsctpserver.h:18
int maximumChannelCount() const
Returns the maximum number of channels that the accepted sockets are able to support.
virtual ~QSctpServer()
Destroys the QSctpServer object.
void setMaximumChannelCount(int count)
Sets the maximum number of channels that the server is prepared to support in datagram mode,...
QSctpServer(QObject *parent=nullptr)
Constructs a QSctpServer object.
QSctpSocket * nextPendingDatagramConnection()
Returns the next pending datagram-mode connection as a connected QSctpSocket object.
void incomingConnection(qintptr handle) override
\reimp
The QSctpSocket class provides an SCTP socket.
Definition qsctpsocket.h:17
iterator begin()
Definition qset.h:136
QAbstractSocketEngine * socketEngine
virtual void configureCreatedSocket()
The QTcpServer class provides a TCP-based server.
Definition qtcpserver.h:22
void addPendingConnection(QTcpSocket *socket)
This function is called by QTcpServer::incomingConnection() to add the socket to the list of pending ...
qintptr socketDescriptor() const
Returns the native socket descriptor the server uses to listen for incoming instructions,...
QSet< QString >::iterator it
Combined button and popup list for selecting options.
#define qDebug
[1]
Definition qlogging.h:164
#define qWarning
Definition qlogging.h:166
GLuint GLuint end
GLenum GLenum GLsizei count
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
ptrdiff_t qintptr
Definition qtypes.h:166
QTcpSocket * socket
[1]