| 1 | /****************************************************************************
|
|---|
| 2 | **
|
|---|
| 3 | ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
|---|
| 4 | ** All rights reserved.
|
|---|
| 5 | ** Contact: Nokia Corporation ([email protected])
|
|---|
| 6 | **
|
|---|
| 7 | ** This file is part of the QtNetwork module of the Qt Toolkit.
|
|---|
| 8 | **
|
|---|
| 9 | ** $QT_BEGIN_LICENSE:LGPL$
|
|---|
| 10 | ** Commercial Usage
|
|---|
| 11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
|---|
| 12 | ** accordance with the Qt Commercial License Agreement provided with the
|
|---|
| 13 | ** Software or, alternatively, in accordance with the terms contained in
|
|---|
| 14 | ** a written agreement between you and Nokia.
|
|---|
| 15 | **
|
|---|
| 16 | ** GNU Lesser General Public License Usage
|
|---|
| 17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
|---|
| 18 | ** General Public License version 2.1 as published by the Free Software
|
|---|
| 19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
|---|
| 20 | ** packaging of this file. Please review the following information to
|
|---|
| 21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
|---|
| 22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|---|
| 23 | **
|
|---|
| 24 | ** In addition, as a special exception, Nokia gives you certain additional
|
|---|
| 25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
|---|
| 26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|---|
| 27 | **
|
|---|
| 28 | ** GNU General Public License Usage
|
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU
|
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software
|
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 32 | ** packaging of this file. Please review the following information to
|
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
|---|
| 35 | **
|
|---|
| 36 | ** If you have questions regarding the use of this file, please contact
|
|---|
| 37 | ** Nokia at [email protected].
|
|---|
| 38 | ** $QT_END_LICENSE$
|
|---|
| 39 | **
|
|---|
| 40 | ****************************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | #ifndef QABSTRACTSOCKET_H
|
|---|
| 43 | #define QABSTRACTSOCKET_H
|
|---|
| 44 |
|
|---|
| 45 | #include <QtCore/qiodevice.h>
|
|---|
| 46 | #include <QtCore/qobject.h>
|
|---|
| 47 | #ifndef QT_NO_DEBUG_STREAM
|
|---|
| 48 | #include <QtCore/qdebug.h>
|
|---|
| 49 | #endif
|
|---|
| 50 |
|
|---|
| 51 | QT_BEGIN_HEADER
|
|---|
| 52 |
|
|---|
| 53 | QT_BEGIN_NAMESPACE
|
|---|
| 54 |
|
|---|
| 55 | QT_MODULE(Network)
|
|---|
| 56 |
|
|---|
| 57 | class QHostAddress;
|
|---|
| 58 | #ifndef QT_NO_NETWORKPROXY
|
|---|
| 59 | class QNetworkProxy;
|
|---|
| 60 | #endif
|
|---|
| 61 | class QAbstractSocketPrivate;
|
|---|
| 62 | class QAuthenticator;
|
|---|
| 63 |
|
|---|
| 64 | class Q_NETWORK_EXPORT QAbstractSocket : public QIODevice
|
|---|
| 65 | {
|
|---|
| 66 | Q_OBJECT
|
|---|
| 67 | public:
|
|---|
| 68 | enum SocketType {
|
|---|
| 69 | TcpSocket,
|
|---|
| 70 | UdpSocket,
|
|---|
| 71 | UnknownSocketType = -1
|
|---|
| 72 | };
|
|---|
| 73 | enum NetworkLayerProtocol {
|
|---|
| 74 | IPv4Protocol,
|
|---|
| 75 | IPv6Protocol,
|
|---|
| 76 | UnknownNetworkLayerProtocol = -1
|
|---|
| 77 | };
|
|---|
| 78 | enum SocketError {
|
|---|
| 79 | ConnectionRefusedError,
|
|---|
| 80 | RemoteHostClosedError,
|
|---|
| 81 | HostNotFoundError,
|
|---|
| 82 | SocketAccessError,
|
|---|
| 83 | SocketResourceError,
|
|---|
| 84 | SocketTimeoutError, /* 5 */
|
|---|
| 85 | DatagramTooLargeError,
|
|---|
| 86 | NetworkError,
|
|---|
| 87 | AddressInUseError,
|
|---|
| 88 | SocketAddressNotAvailableError,
|
|---|
| 89 | UnsupportedSocketOperationError, /* 10 */
|
|---|
| 90 | UnfinishedSocketOperationError,
|
|---|
| 91 | ProxyAuthenticationRequiredError,
|
|---|
| 92 | SslHandshakeFailedError,
|
|---|
| 93 | ProxyConnectionRefusedError,
|
|---|
| 94 | ProxyConnectionClosedError, /* 15 */
|
|---|
| 95 | ProxyConnectionTimeoutError,
|
|---|
| 96 | ProxyNotFoundError,
|
|---|
| 97 | ProxyProtocolError,
|
|---|
| 98 |
|
|---|
| 99 | UnknownSocketError = -1
|
|---|
| 100 | };
|
|---|
| 101 | enum SocketState {
|
|---|
| 102 | UnconnectedState,
|
|---|
| 103 | HostLookupState,
|
|---|
| 104 | ConnectingState,
|
|---|
| 105 | ConnectedState,
|
|---|
| 106 | BoundState,
|
|---|
| 107 | ListeningState,
|
|---|
| 108 | ClosingState
|
|---|
| 109 | #ifdef QT3_SUPPORT
|
|---|
| 110 | ,
|
|---|
| 111 | Idle = UnconnectedState,
|
|---|
| 112 | HostLookup = HostLookupState,
|
|---|
| 113 | Connecting = ConnectingState,
|
|---|
| 114 | Connected = ConnectedState,
|
|---|
| 115 | Closing = ClosingState,
|
|---|
| 116 | Connection = ConnectedState
|
|---|
| 117 | #endif
|
|---|
| 118 | };
|
|---|
| 119 | enum SocketOption {
|
|---|
| 120 | LowDelayOption, // TCP_NODELAY
|
|---|
| 121 | KeepAliveOption // SO_KEEPALIVE
|
|---|
| 122 | };
|
|---|
| 123 |
|
|---|
| 124 | QAbstractSocket(SocketType socketType, QObject *parent);
|
|---|
| 125 | virtual ~QAbstractSocket();
|
|---|
| 126 |
|
|---|
| 127 | // ### Qt 5: Make connectToHost() and disconnectFromHost() virtual.
|
|---|
| 128 | void connectToHost(const QString &hostName, quint16 port, OpenMode mode = ReadWrite);
|
|---|
| 129 | void connectToHost(const QHostAddress &address, quint16 port, OpenMode mode = ReadWrite);
|
|---|
| 130 | void disconnectFromHost();
|
|---|
| 131 |
|
|---|
| 132 | bool isValid() const;
|
|---|
| 133 |
|
|---|
|
|---|