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
qtcpserver.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QTCPSERVER_H
5#define QTCPSERVER_H
6
7#include <QtNetwork/qtnetworkglobal.h>
8#include <QtCore/qobject.h>
9#include <QtNetwork/qabstractsocket.h>
10#include <QtNetwork/qhostaddress.h>
11
13
14
16#ifndef QT_NO_NETWORKPROXY
17class QNetworkProxy;
18#endif
19class QTcpSocket;
20
21class Q_NETWORK_EXPORT QTcpServer : public QObject
22{
24public:
25 explicit QTcpServer(QObject *parent = nullptr);
26 virtual ~QTcpServer();
27
29 void close();
30
31 bool isListening() const;
32
33 void setMaxPendingConnections(int numConnections);
34 int maxPendingConnections() const;
35
36 void setListenBacklogSize(int size);
37 int listenBacklogSize() const;
38
39 quint16 serverPort() const;
40 QHostAddress serverAddress() const;
41
42 qintptr socketDescriptor() const;
43 bool setSocketDescriptor(qintptr socketDescriptor);
44
45 bool waitForNewConnection(int msec = 0, bool *timedOut = nullptr);
46 virtual bool hasPendingConnections() const;
47 virtual QTcpSocket *nextPendingConnection();
48
49 QAbstractSocket::SocketError serverError() const;
50 QString errorString() const;
51
52 void pauseAccepting();
53 void resumeAccepting();
54
55#ifndef QT_NO_NETWORKPROXY
56 void setProxy(const QNetworkProxy &networkProxy);
57 QNetworkProxy proxy() const;
58#endif
59
60protected:
61 virtual void incomingConnection(qintptr handle);
62 void addPendingConnection(QTcpSocket* socket);
63
65 QObject *parent = nullptr);
66
69 void pendingConnectionAvailable(QPrivateSignal);
71
72private:
73 Q_DISABLE_COPY(QTcpServer)
74 Q_DECLARE_PRIVATE(QTcpServer)
75};
76
78
79#endif // QTCPSERVER_H
SocketError
This enum describes the socket errors that can occur.
SocketType
This enum describes the transport layer protocol.
The QHostAddress class provides an IP address.
The QNetworkProxy class provides a network layer proxy.
\inmodule QtCore
Definition qobject.h:103
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
The QTcpServer class provides a TCP-based server.
Definition qtcpserver.h:22
void newConnection()
This signal is emitted every time a new connection is available, regardless of whether it has been ad...
void acceptError(QAbstractSocket::SocketError socketError)
void pendingConnectionAvailable(QPrivateSignal)
This signal is emitted every time a new connection has been added to the pending connections queue.
The QTcpSocket class provides a TCP socket.
Definition qtcpsocket.h:18
Combined button and popup list for selecting options.
EGLOutputPortEXT port
static QT_BEGIN_NAMESPACE const char * socketType(QSocketNotifier::Type type)
GLuint64 GLenum void * handle
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLuint64EXT address
#define Q_OBJECT
#define Q_SIGNALS
unsigned short quint16
Definition qtypes.h:48
ptrdiff_t qintptr
Definition qtypes.h:166
QTcpSocket * socket
[1]
QNetworkProxy proxy
[0]
serverSocket setProxy(QNetworkProxy::NoProxy)
[0]
socketLayer listen()