summaryrefslogtreecommitdiffstats
path: root/src/network/socket
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/socket')
-rw-r--r--src/network/socket/qabstractsocket.cpp116
-rw-r--r--src/network/socket/qabstractsocket.h44
-rw-r--r--src/network/socket/qabstractsocket_p.h17
-rw-r--r--src/network/socket/qabstractsocketengine.cpp14
-rw-r--r--src/network/socket/qabstractsocketengine_p.h14
-rw-r--r--src/network/socket/qhttpsocketengine.cpp14
-rw-r--r--src/network/socket/qhttpsocketengine_p.h84
-rw-r--r--src/network/socket/qlocalserver.cpp14
-rw-r--r--src/network/socket/qlocalserver.h14
-rw-r--r--src/network/socket/qlocalserver_p.h14
-rw-r--r--src/network/socket/qlocalserver_tcp.cpp14
-rw-r--r--src/network/socket/qlocalserver_unix.cpp14
-rw-r--r--src/network/socket/qlocalserver_win.cpp14
-rw-r--r--src/network/socket/qlocalsocket.cpp18
-rw-r--r--src/network/socket/qlocalsocket.h32
-rw-r--r--src/network/socket/qlocalsocket_p.h14
-rw-r--r--src/network/socket/qlocalsocket_tcp.cpp14
-rw-r--r--src/network/socket/qlocalsocket_unix.cpp14
-rw-r--r--src/network/socket/qlocalsocket_win.cpp17
-rw-r--r--src/network/socket/qnativesocketengine.cpp62
-rw-r--r--src/network/socket/qnativesocketengine_p.h81
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp260
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp187
-rw-r--r--src/network/socket/qnativesocketengine_winrt.cpp95
-rw-r--r--src/network/socket/qnativesocketengine_winrt_p.h15
-rw-r--r--src/network/socket/qnet_unix_p.h14
-rw-r--r--src/network/socket/qsocks5socketengine.cpp20
-rw-r--r--src/network/socket/qsocks5socketengine_p.h96
-rw-r--r--src/network/socket/qtcpserver.cpp61
-rw-r--r--src/network/socket/qtcpserver.h16
-rw-r--r--src/network/socket/qtcpserver_p.h97
-rw-r--r--src/network/socket/qtcpsocket.cpp14
-rw-r--r--src/network/socket/qtcpsocket.h14
-rw-r--r--src/network/socket/qtcpsocket_p.h14
-rw-r--r--src/network/socket/qudpsocket.cpp14
-rw-r--r--src/network/socket/qudpsocket.h14
-rw-r--r--src/network/socket/socket.pri3
37 files changed, 809 insertions, 764 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 26667715be..f5dcdcba1c 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -549,7 +549,6 @@ QAbstractSocketPrivate::QAbstractSocketPrivate()
emittedReadyRead(false),
emittedBytesWritten(false),
abortCalled(false),
- closeCalled(false),
pendingClose(false),
pauseMode(QAbstractSocket::PauseNever),
port(0),
@@ -977,7 +976,7 @@ void QAbstractSocketPrivate::startConnectingByName(const QString &host)
connectTimeElapsed = 0;
- if (initSocketLayer(QAbstractSocket::UnknownNetworkLayerProtocol)) {
+ if (cachedSocketDescriptor != -1 || initSocketLayer(QAbstractSocket::UnknownNetworkLayerProtocol)) {
if (socketEngine->connectToHostByName(host, port) ||
socketEngine->state() == QAbstractSocket::ConnectingState) {
cachedSocketDescriptor = socketEngine->socketDescriptor();
@@ -1118,7 +1117,7 @@ void QAbstractSocketPrivate::_q_connectToNextAddress()
host.toString().toLatin1().constData(), port, addresses.count());
#endif
- if (!initSocketLayer(host.protocol())) {
+ if (cachedSocketDescriptor == -1 && !initSocketLayer(host.protocol())) {
// hope that the next address is better
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocketPrivate::_q_connectToNextAddress(), failed to initialize sock layer");
@@ -1135,9 +1134,6 @@ void QAbstractSocketPrivate::_q_connectToNextAddress()
return;
}
- // cache the socket descriptor even if we're not fully connected yet
- cachedSocketDescriptor = socketEngine->socketDescriptor();
-
// Check that we're in delayed connection state. If not, try
// the next address
if (socketEngine->state() != QAbstractSocket::ConnectingState) {
@@ -1269,8 +1265,8 @@ bool QAbstractSocketPrivate::readFromSocket()
bytesToRead = readBufferMaxSize - buffer.size();
#if defined(QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocketPrivate::readFromSocket() about to read %d bytes",
- int(bytesToRead));
+ qDebug("QAbstractSocketPrivate::readFromSocket() about to read %lld bytes",
+ bytesToRead);
#endif
// Read from the socket, store data in the read buffer.
@@ -1281,10 +1277,10 @@ bool QAbstractSocketPrivate::readFromSocket()
buffer.chop(bytesToRead);
return true;
}
- buffer.chop(int(bytesToRead - (readBytes < 0 ? qint64(0) : readBytes)));
+ buffer.chop(bytesToRead - (readBytes < 0 ? qint64(0) : readBytes));
#if defined(QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocketPrivate::readFromSocket() got %d bytes, buffer size = %d",
- int(readBytes), buffer.size());
+ qDebug("QAbstractSocketPrivate::readFromSocket() got %lld bytes, buffer size = %lld",
+ readBytes, buffer.size());
#endif
if (!socketEngine->isValid()) {
@@ -1482,54 +1478,60 @@ void QAbstractSocket::setPauseMode(PauseModes pauseMode)
bool QAbstractSocket::bind(const QHostAddress &address, quint16 port, BindMode mode)
{
Q_D(QAbstractSocket);
+ return d->bind(address, port, mode);
+}
+
+bool QAbstractSocketPrivate::bind(const QHostAddress &address, quint16 port, QAbstractSocket::BindMode mode)
+{
+ Q_Q(QAbstractSocket);
// now check if the socket engine is initialized and to the right type
- if (!d->socketEngine || !d->socketEngine->isValid()) {
+ if (!socketEngine || !socketEngine->isValid()) {
QHostAddress nullAddress;
- d->resolveProxy(nullAddress.toString(), port);
+ resolveProxy(nullAddress.toString(), port);
QAbstractSocket::NetworkLayerProtocol protocol = address.protocol();
if (protocol == QAbstractSocket::UnknownNetworkLayerProtocol)
protocol = nullAddress.protocol();
- if (!d->initSocketLayer(protocol))
+ if (!initSocketLayer(protocol))
return false;
}
- if (mode != DefaultForPlatform) {
+ if (mode != QAbstractSocket::DefaultForPlatform) {
#ifdef Q_OS_UNIX
- if ((mode & ShareAddress) || (mode & ReuseAddressHint))
- d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1);
+ if ((mode & QAbstractSocket::ShareAddress) || (mode & QAbstractSocket::ReuseAddressHint))
+ socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1);
else
- d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 0);
+ socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 0);
#endif
#ifdef Q_OS_WIN
- if (mode & ReuseAddressHint)
- d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1);
+ if (mode & QAbstractSocket::ReuseAddressHint)
+ socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 1);
else
- d->socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 0);
- if (mode & DontShareAddress)
- d->socketEngine->setOption(QAbstractSocketEngine::BindExclusively, 1);
+ socketEngine->setOption(QAbstractSocketEngine::AddressReusable, 0);
+ if (mode & QAbstractSocket::DontShareAddress)
+ socketEngine->setOption(QAbstractSocketEngine::BindExclusively, 1);
else
- d->socketEngine->setOption(QAbstractSocketEngine::BindExclusively, 0);
+ socketEngine->setOption(QAbstractSocketEngine::BindExclusively, 0);
#endif
}
- bool result = d->socketEngine->bind(address, port);
- d->cachedSocketDescriptor = d->socketEngine->socketDescriptor();
+ bool result = socketEngine->bind(address, port);
+ cachedSocketDescriptor = socketEngine->socketDescriptor();
if (!result) {
- d->socketError = d->socketEngine->error();
- setErrorString(d->socketEngine->errorString());
- emit error(d->socketError);
+ socketError = socketEngine->error();
+ q->setErrorString(socketEngine->errorString());
+ emit q->error(socketError);
return false;
}
- d->state = BoundState;
- d->localAddress = d->socketEngine->localAddress();
- d->localPort = d->socketEngine->localPort();
+ state = QAbstractSocket::BoundState;
+ localAddress = socketEngine->localAddress();
+ localPort = socketEngine->localPort();
- emit stateChanged(d->state);
- d->socketEngine->setReadNotificationEnabled(true);
+ emit q->stateChanged(state);
+ socketEngine->setReadNotificationEnabled(true);
return true;
}
@@ -1606,15 +1608,16 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port,
d->preferredNetworkLayerProtocol = protocol;
d->hostName = hostName;
d->port = port;
- d->state = UnconnectedState;
d->buffer.clear();
d->writeBuffer.clear();
d->abortCalled = false;
- d->closeCalled = false;
d->pendingClose = false;
- d->localPort = 0;
+ if (d->state != BoundState) {
+ d->state = UnconnectedState;
+ d->localPort = 0;
+ d->localAddress.clear();
+ }
d->peerPort = 0;
- d->localAddress.clear();
d->peerAddress.clear();
d->peerName = hostName;
if (d->hostLookupId != -1) {
@@ -1723,7 +1726,7 @@ qint64 QAbstractSocket::bytesAvailable() const
available += d->socketEngine->bytesAvailable();
#if defined(QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocket::bytesAvailable() == %llu", available);
+ qDebug("QAbstractSocket::bytesAvailable() == %lld", available);
#endif
return available;
}
@@ -1802,8 +1805,8 @@ bool QAbstractSocket::canReadLine() const
{
bool hasLine = d_func()->buffer.canReadLine();
#if defined (QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocket::canReadLine() == %s, buffer size = %d, size = %d", hasLine ? "true" : "false",
- d_func()->buffer.size(), d_func()->buffer.size());
+ qDebug("QAbstractSocket::canReadLine() == %s, buffer size = %lld, size = %lld",
+ hasLine ? "true" : "false", d_func()->buffer.size(), d_func()->buffer.size());
#endif
return hasLine || QIODevice::canReadLine();
}
@@ -2636,10 +2639,8 @@ void QAbstractSocket::close()
qDebug("QAbstractSocket::close()");
#endif
QIODevice::close();
- if (d->state != UnconnectedState) {
- d->closeCalled = true;
+ if (d->state != UnconnectedState)
disconnectFromHost();
- }
d->localPort = 0;
d->peerPort = 0;
@@ -2749,19 +2750,12 @@ void QAbstractSocket::disconnectFromHost()
d->peerPort = 0;
d->localAddress.clear();
d->peerAddress.clear();
+ d->writeBuffer.clear();
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocket::disconnectFromHost() disconnected!");
#endif
- if (d->closeCalled) {
-#if defined(QABSTRACTSOCKET_DEBUG)
- qDebug("QAbstractSocket::disconnectFromHost() closed!");
-#endif
- d->buffer.clear();
- d->writeBuffer.clear();
- QIODevice::close();
- }
}
/*!
@@ -2912,6 +2906,8 @@ QNetworkProxy QAbstractSocket::proxy() const
#ifndef QT_NO_DEBUG_STREAM
Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, QAbstractSocket::SocketError error)
{
+ QDebugStateSaver saver(debug);
+ debug.resetFormat().nospace();
switch (error) {
case QAbstractSocket::ConnectionRefusedError:
debug << "QAbstractSocket::ConnectionRefusedError";
@@ -2979,6 +2975,8 @@ Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, QAbstractSocket::SocketError er
Q_NETWORK_EXPORT QDebug operator<<(QDebug debug, QAbstractSocket::SocketState state)
{
+ QDebugStateSaver saver(debug);
+ debug.resetFormat().nospace();
switch (state) {
case QAbstractSocket::UnconnectedState:
debug << "QAbstractSocket::UnconnectedState";
diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h
index 35e9ea1aac..f3d7f13f48 100644
--- a/src/network/socket/qabstractsocket.h
+++ b/src/network/socket/qabstractsocket.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -53,19 +53,20 @@ class QAuthenticator;
class Q_NETWORK_EXPORT QAbstractSocket : public QIODevice
{
Q_OBJECT
- Q_ENUMS(SocketType NetworkLayerProtocol SocketError SocketState SocketOption)
public:
enum SocketType {
TcpSocket,
UdpSocket,
UnknownSocketType = -1
};
+ Q_ENUM(SocketType)
enum NetworkLayerProtocol {
IPv4Protocol,
IPv6Protocol,
AnyIPProtocol,
UnknownNetworkLayerProtocol = -1
};
+ Q_ENUM(NetworkLayerProtocol)
enum SocketError {
ConnectionRefusedError,
RemoteHostClosedError,
@@ -93,6 +94,7 @@ public:
UnknownSocketError = -1
};
+ Q_ENUM(SocketError)
enum SocketState {
UnconnectedState,
HostLookupState,
@@ -102,6 +104,7 @@ public:
ListeningState,
ClosingState
};
+ Q_ENUM(SocketState)
enum SocketOption {
LowDelayOption, // TCP_NODELAY
KeepAliveOption, // SO_KEEPALIVE
@@ -111,6 +114,7 @@ public:
SendBufferSizeSocketOption, //SO_SNDBUF
ReceiveBufferSizeSocketOption //SO_RCVBUF
};
+ Q_ENUM(SocketOption)
enum BindFlag {
DefaultForPlatform = 0x0,
ShareAddress = 0x1,
@@ -131,19 +135,21 @@ public:
PauseModes pauseMode() const;
void setPauseMode(PauseModes pauseMode);
+ // ### Qt6: make the first one virtual
bool bind(const QHostAddress &address, quint16 port = 0, BindMode mode = DefaultForPlatform);
bool bind(quint16 port = 0, BindMode mode = DefaultForPlatform);
+ // ### Qt6: de-virtualize connectToHost(QHostAddress) overload
virtual void connectToHost(const QString &hostName, quint16 port, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
virtual void connectToHost(const QHostAddress &address, quint16 port, OpenMode mode = ReadWrite);
virtual void disconnectFromHost();
bool isValid() const;
- qint64 bytesAvailable() const;
- qint64 bytesToWrite() const;
+ qint64 bytesAvailable() const Q_DECL_OVERRIDE;
+ qint64 bytesToWrite() const Q_DECL_OVERRIDE;
- bool canReadLine() const;
+ bool canReadLine() const Q_DECL_OVERRIDE;
quint16 localPort() const;
QHostAddress localAddress() const;
@@ -168,15 +174,15 @@ public:
SocketError error() const;
// from QIODevice
- void close();
- bool isSequential() const;
- bool atEnd() const;
+ void close() Q_DECL_OVERRIDE;
+ bool isSequential() const Q_DECL_OVERRIDE;
+ bool atEnd() const Q_DECL_OVERRIDE;
bool flush();
// for synchronous access
virtual bool waitForConnected(int msecs = 30000);
- bool waitForReadyRead(int msecs = 30000);
- bool waitForBytesWritten(int msecs = 30000);
+ bool waitForReadyRead(int msecs = 30000) Q_DECL_OVERRIDE;
+ bool waitForBytesWritten(int msecs = 30000) Q_DECL_OVERRIDE;
virtual bool waitForDisconnected(int msecs = 30000);
#ifndef QT_NO_NETWORKPROXY
@@ -195,9 +201,9 @@ Q_SIGNALS:
#endif
protected:
- qint64 readData(char *data, qint64 maxlen);
- qint64 readLineData(char *data, qint64 maxlen);
- qint64 writeData(const char *data, qint64 len);
+ qint64 readData(char *data, qint64 maxlen) Q_DECL_OVERRIDE;
+ qint64 readLineData(char *data, qint64 maxlen) Q_DECL_OVERRIDE;
+ qint64 writeData(const char *data, qint64 len) Q_DECL_OVERRIDE;
void setSocketState(SocketState state);
void setSocketError(SocketError socketError);
diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h
index 6d260228de..63440b6416 100644
--- a/src/network/socket/qabstractsocket_p.h
+++ b/src/network/socket/qabstractsocket_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -78,6 +78,8 @@ public:
}
#endif
+ virtual bool bind(const QHostAddress &address, quint16 port, QAbstractSocket::BindMode mode);
+
bool canReadNotification();
bool canWriteNotification();
void canCloseNotification();
@@ -97,7 +99,6 @@ public:
bool emittedBytesWritten;
bool abortCalled;
- bool closeCalled;
bool pendingClose;
QAbstractSocket::PauseModes pauseMode;
diff --git a/src/network/socket/qabstractsocketengine.cpp b/src/network/socket/qabstractsocketengine.cpp
index a22f23bcc5..cb784159cc 100644
--- a/src/network/socket/qabstractsocketengine.cpp
+++ b/src/network/socket/qabstractsocketengine.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qabstractsocketengine_p.h b/src/network/socket/qabstractsocketengine_p.h
index cde7c1159d..f2a3149678 100644
--- a/src/network/socket/qabstractsocketengine_p.h
+++ b/src/network/socket/qabstractsocketengine_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp
index 7b601db79d..23347ce08b 100644
--- a/src/network/socket/qhttpsocketengine.cpp
+++ b/src/network/socket/qhttpsocketengine.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qhttpsocketengine_p.h b/src/network/socket/qhttpsocketengine_p.h
index 0448293981..4d90487679 100644
--- a/src/network/socket/qhttpsocketengine_p.h
+++ b/src/network/socket/qhttpsocketengine_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -73,63 +73,63 @@ public:
QHttpSocketEngine(QObject *parent = 0);
~QHttpSocketEngine();
- bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol);
- bool initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState);
+ bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol) Q_DECL_OVERRIDE;
+ bool initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState) Q_DECL_OVERRIDE;
void setProxy(const QNetworkProxy &networkProxy);
- qintptr socketDescriptor() const;
+ qintptr socketDescriptor() const Q_DECL_OVERRIDE;
- bool isValid() const;
+ bool isValid() const Q_DECL_OVERRIDE;
bool connectInternal();
- bool connectToHost(const QHostAddress &address, quint16 port);
- bool connectToHostByName(const QString &name, quint16 port);
- bool bind(const QHostAddress &address, quint16 port);
- bool listen();
- int accept();
- void close();
+ bool connectToHost(const QHostAddress &address, quint16 port) Q_DECL_OVERRIDE;
+ bool connectToHostByName(const QString &name, quint16 port) Q_DECL_OVERRIDE;
+ bool bind(const QHostAddress &address, quint16 port) Q_DECL_OVERRIDE;
+ bool listen() Q_DECL_OVERRIDE;
+ int accept() Q_DECL_OVERRIDE;
+ void close() Q_DECL_OVERRIDE;
- qint64 bytesAvailable() const;
+ qint64 bytesAvailable() const Q_DECL_OVERRIDE;
- qint64 read(char *data, qint64 maxlen);
- qint64 write(const char *data, qint64 len);
+ qint64 read(char *data, qint64 maxlen) Q_DECL_OVERRIDE;
+ qint64 write(const char *data, qint64 len) Q_DECL_OVERRIDE;
#ifndef QT_NO_UDPSOCKET
#ifndef QT_NO_NETWORKINTERFACE
bool joinMulticastGroup(const QHostAddress &groupAddress,
- const QNetworkInterface &interface);
+ const QNetworkInterface &interface) Q_DECL_OVERRIDE;
bool leaveMulticastGroup(const QHostAddress &groupAddress,
- const QNetworkInterface &interface);
- QNetworkInterface multicastInterface() const;
- bool setMulticastInterface(const QNetworkInterface &iface);
+ const QNetworkInterface &interface) Q_DECL_OVERRIDE;
+ QNetworkInterface multicastInterface() const Q_DECL_OVERRIDE;
+ bool setMulticastInterface(const QNetworkInterface &iface) Q_DECL_OVERRIDE;
#endif // QT_NO_NETWORKINTERFACE
qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *addr = 0,
- quint16 *port = 0);
+ quint16 *port = 0) Q_DECL_OVERRIDE;
qint64 writeDatagram(const char *data, qint64 len, const QHostAddress &addr,
- quint16 port);
- bool hasPendingDatagrams() const;
- qint64 pendingDatagramSize() const;
+ quint16 port) Q_DECL_OVERRIDE;
+ bool hasPendingDatagrams() const Q_DECL_OVERRIDE;
+ qint64 pendingDatagramSize() const Q_DECL_OVERRIDE;
#endif // QT_NO_UDPSOCKET
- qint64 bytesToWrite() const;
+ qint64 bytesToWrite() const Q_DECL_OVERRIDE;
- int option(SocketOption option) const;
- bool setOption(SocketOption option, int value);
+ int option(SocketOption option) const Q_DECL_OVERRIDE;
+ bool setOption(SocketOption option, int value) Q_DECL_OVERRIDE;
- bool waitForRead(int msecs = 30000, bool *timedOut = 0);
- bool waitForWrite(int msecs = 30000, bool *timedOut = 0);
+ bool waitForRead(int msecs = 30000, bool *timedOut = 0) Q_DECL_OVERRIDE;
+ bool waitForWrite(int msecs = 30000, bool *timedOut = 0) Q_DECL_OVERRIDE;
bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite,
bool checkRead, bool checkWrite,
- int msecs = 30000, bool *timedOut = 0);
+ int msecs = 30000, bool *timedOut = 0) Q_DECL_OVERRIDE;
- bool isReadNotificationEnabled() const;
- void setReadNotificationEnabled(bool enable);
- bool isWriteNotificationEnabled() const;
- void setWriteNotificationEnabled(bool enable);
- bool isExceptionNotificationEnabled() const;
- void setExceptionNotificationEnabled(bool enable);
+ bool isReadNotificationEnabled() const Q_DECL_OVERRIDE;
+ void setReadNotificationEnabled(bool enable) Q_DECL_OVERRIDE;
+ bool isWriteNotificationEnabled() const Q_DECL_OVERRIDE;
+ void setWriteNotificationEnabled(bool enable) Q_DECL_OVERRIDE;
+ bool isExceptionNotificationEnabled() const Q_DECL_OVERRIDE;
+ void setExceptionNotificationEnabled(bool enable) Q_DECL_OVERRIDE;
public slots:
void slotSocketConnected();
@@ -186,8 +186,8 @@ class Q_AUTOTEST_EXPORT QHttpSocketEngineHandler : public QSocketEngineHandler
{
public:
virtual QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType,
- const QNetworkProxy &, QObject *parent);
- virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescripter, QObject *parent);
+ const QNetworkProxy &, QObject *parent) Q_DECL_OVERRIDE;
+ virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescripter, QObject *parent) Q_DECL_OVERRIDE;
};
#endif
diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp
index 39a892d9f9..5854466704 100644
--- a/src/network/socket/qlocalserver.cpp
+++ b/src/network/socket/qlocalserver.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qlocalserver.h b/src/network/socket/qlocalserver.h
index c22ab89312..a03cdb726d 100644
--- a/src/network/socket/qlocalserver.h
+++ b/src/network/socket/qlocalserver.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qlocalserver_p.h b/src/network/socket/qlocalserver_p.h
index b241009751..79ebac9320 100644
--- a/src/network/socket/qlocalserver_p.h
+++ b/src/network/socket/qlocalserver_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qlocalserver_tcp.cpp b/src/network/socket/qlocalserver_tcp.cpp
index 58cbf998f5..7a5a92984d 100644
--- a/src/network/socket/qlocalserver_tcp.cpp
+++ b/src/network/socket/qlocalserver_tcp.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp
index a615dcc7b6..ef10b1e68d 100644
--- a/src/network/socket/qlocalserver_unix.cpp
+++ b/src/network/socket/qlocalserver_unix.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qlocalserver_win.cpp b/src/network/socket/qlocalserver_win.cpp
index 36e8c948f0..265f894972 100644
--- a/src/network/socket/qlocalserver_win.cpp
+++ b/src/network/socket/qlocalserver_win.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp
index c1beedd53e..990b282071 100644
--- a/src/network/socket/qlocalsocket.cpp
+++ b/src/network/socket/qlocalsocket.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -487,6 +487,8 @@ bool QLocalSocket::isSequential() const
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug debug, QLocalSocket::LocalSocketError error)
{
+ QDebugStateSaver saver(debug);
+ debug.resetFormat().nospace();
switch (error) {
case QLocalSocket::ConnectionRefusedError:
debug << "QLocalSocket::ConnectionRefusedError";
@@ -527,6 +529,8 @@ QDebug operator<<(QDebug debug, QLocalSocket::LocalSocketError error)
QDebug operator<<(QDebug debug, QLocalSocket::LocalSocketState state)
{
+ QDebugStateSaver saver(debug);
+ debug.resetFormat().nospace();
switch (state) {
case QLocalSocket::UnconnectedState:
debug << "QLocalSocket::UnconnectedState";
diff --git a/src/network/socket/qlocalsocket.h b/src/network/socket/qlocalsocket.h
index c0429d3a1f..a4d8405912 100644
--- a/src/network/socket/qlocalsocket.h
+++ b/src/network/socket/qlocalsocket.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -85,12 +85,12 @@ public:
QString fullServerName() const;
void abort();
- virtual bool isSequential() const;
- virtual qint64 bytesAvailable() const;
- virtual qint64 bytesToWrite() const;
- virtual bool canReadLine() const;
+ virtual bool isSequential() const Q_DECL_OVERRIDE;
+ virtual qint64 bytesAvailable() const Q_DECL_OVERRIDE;
+ virtual qint64 bytesToWrite() const Q_DECL_OVERRIDE;
+ virtual bool canReadLine() const Q_DECL_OVERRIDE;
virtual bool open(OpenMode openMode = ReadWrite) Q_DECL_OVERRIDE;
- virtual void close();
+ virtual void close() Q_DECL_OVERRIDE;
LocalSocketError error() const;
bool flush();
bool isValid() const;
@@ -103,10 +103,10 @@ public:
qintptr socketDescriptor() const;
LocalSocketState state() const;
- bool waitForBytesWritten(int msecs = 30000);
+ bool waitForBytesWritten(int msecs = 30000) Q_DECL_OVERRIDE;
bool waitForConnected(int msecs = 30000);
bool waitForDisconnected(int msecs = 30000);
- bool waitForReadyRead(int msecs = 30000);
+ bool waitForReadyRead(int msecs = 30000) Q_DECL_OVERRIDE;
Q_SIGNALS:
void connected();
@@ -115,8 +115,8 @@ Q_SIGNALS:
void stateChanged(QLocalSocket::LocalSocketState socketState);
protected:
- virtual qint64 readData(char*, qint64);
- virtual qint64 writeData(const char*, qint64);
+ virtual qint64 readData(char*, qint64) Q_DECL_OVERRIDE;
+ virtual qint64 writeData(const char*, qint64) Q_DECL_OVERRIDE;
private:
Q_DISABLE_COPY(QLocalSocket)
diff --git a/src/network/socket/qlocalsocket_p.h b/src/network/socket/qlocalsocket_p.h
index 6680e0332f..46c93c01f7 100644
--- a/src/network/socket/qlocalsocket_p.h
+++ b/src/network/socket/qlocalsocket_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp
index 30cc67c4b1..c0140e574e 100644
--- a/src/network/socket/qlocalsocket_tcp.cpp
+++ b/src/network/socket/qlocalsocket_tcp.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp
index 1f6d42918e..77c5028fb3 100644
--- a/src/network/socket/qlocalsocket_unix.cpp
+++ b/src/network/socket/qlocalsocket_unix.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp
index 71016f131a..ae39f78fe8 100644
--- a/src/network/socket/qlocalsocket_win.cpp
+++ b/src/network/socket/qlocalsocket_win.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -405,9 +405,6 @@ bool QLocalSocket::waitForReadyRead(int msecs)
{
Q_D(QLocalSocket);
- if (bytesAvailable() > 0)
- return true;
-
if (d->state != QLocalSocket::ConnectedState)
return false;
diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp
index 63f50632d2..52e6922b5f 100644
--- a/src/network/socket/qnativesocketengine.cpp
+++ b/src/network/socket/qnativesocketengine.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -136,6 +136,12 @@ QT_BEGIN_NAMESPACE
" not in "#state1" or "#state2); \
return (returnValue); \
} } while (0)
+#define Q_CHECK_STATES3(function, state1, state2, state3, returnValue) do { \
+ if (d->socketState != (state1) && d->socketState != (state2) && d->socketState != (state3)) { \
+ qWarning(""#function" was called" \
+ " not in "#state1" or "#state2); \
+ return (returnValue); \
+ } } while (0)
#define Q_CHECK_TYPE(function, type, returnValue) do { \
if (d->socketType != (type)) { \
qWarning(#function" was called by a" \
@@ -275,6 +281,38 @@ void QNativeSocketEnginePrivate::setError(QAbstractSocket::SocketError error, Er
}
}
+/*!
+ \internal
+
+ Adjusts the incoming \a address family to match the currently bound address
+ (if any). This function will convert v4-mapped IPv6 addresses to IPv4 and
+ vice-versa. All other address types and values will be left unchanged.
+ */
+QHostAddress QNativeSocketEnginePrivate::adjustAddressProtocol(const QHostAddress &address) const
+{
+ QAbstractSocket::NetworkLayerProtocol targetProtocol = socketProtocol;
+ if (Q_LIKELY(targetProtocol == QAbstractSocket::UnknownNetworkLayerProtocol))
+ return address;
+
+ QAbstractSocket::NetworkLayerProtocol sourceProtocol = address.protocol();
+
+ if (targetProtocol == QAbstractSocket::AnyIPProtocol)
+ targetProtocol = QAbstractSocket::IPv6Protocol;
+ if (targetProtocol == QAbstractSocket::IPv6Protocol && sourceProtocol == QAbstractSocket::IPv4Protocol) {
+ // convert to IPv6 v4-mapped address. This always works
+ return QHostAddress(address.toIPv6Address());
+ }
+
+ if (targetProtocol == QAbstractSocket::IPv4Protocol && sourceProtocol == QAbstractSocket::IPv6Protocol) {
+ // convert to IPv4 if the source is a v4-mapped address
+ quint32 ip4 = address.toIPv4Address();
+ if (ip4)
+ return QHostAddress(ip4);
+ }
+
+ return address;
+}
+
bool QNativeSocketEnginePrivate::checkProxy(const QHostAddress &address)
{
if (address.isLoopback())
@@ -495,12 +533,12 @@ bool QNativeSocketEngine::connectToHost(const QHostAddress &address, quint16 por
if (!d->checkProxy(address))
return false;
- Q_CHECK_STATES(QNativeSocketEngine::connectToHost(),
+ Q_CHECK_STATES3(QNativeSocketEngine::connectToHost(), QAbstractSocket::BoundState,
QAbstractSocket::UnconnectedState, QAbstractSocket::ConnectingState, false);
d->peerAddress = address;
d->peerPort = port;
- bool connected = d->nativeConnect(address, port);
+ bool connected = d->nativeConnect(d->adjustAddressProtocol(address), port);
if (connected)
d->fetchConnectionParameters();
@@ -560,7 +598,7 @@ bool QNativeSocketEngine::bind(const QHostAddress &address, quint16 port)
Q_CHECK_STATE(QNativeSocketEngine::bind(), QAbstractSocket::UnconnectedState, false);
- if (!d->nativeBind(address, port))
+ if (!d->nativeBind(d->adjustAddressProtocol(address), port))
return false;
d->fetchConnectionParameters();
@@ -770,7 +808,7 @@ qint64 QNativeSocketEngine::writeDatagram(const char *data, qint64 size,
Q_D(QNativeSocketEngine);
Q_CHECK_VALID_SOCKETLAYER(QNativeSocketEngine::writeDatagram(), -1);
Q_CHECK_TYPE(QNativeSocketEngine::writeDatagram(), QAbstractSocket::UdpSocket, -1);
- return d->nativeSendDatagram(data, size, host, port);
+ return d->nativeSendDatagram(data, size, d->adjustAddressProtocol(host), port);
}
/*!
@@ -961,7 +999,7 @@ bool QNativeSocketEngine::waitForWrite(int msecs, bool *timedOut)
QNativeSocketEnginePrivate::TimeOutErrorString);
d->hasSetSocketError = false; // A timeout error is temporary in waitFor functions
return false;
- } else if (state() == QAbstractSocket::ConnectingState) {
+ } else if (state() == QAbstractSocket::ConnectingState || (state() == QAbstractSocket::BoundState && d->socketDescriptor != -1)) {
connectToHost(d->peerAddress, d->peerPort);
}
diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h
index 67412ca326..24909bf310 100644
--- a/src/network/socket/qnativesocketengine_p.h
+++ b/src/network/socket/qnativesocketengine_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -105,42 +105,42 @@ public:
QNativeSocketEngine(QObject *parent = 0);
~QNativeSocketEngine();
- bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol);
- bool initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState);
+ bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol) Q_DECL_OVERRIDE;
+ bool initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState) Q_DECL_OVERRIDE;
- qintptr socketDescriptor() const;
+ qintptr socketDescriptor() const Q_DECL_OVERRIDE;
- bool isValid() const;
+ bool isValid() const Q_DECL_OVERRIDE;
- bool connectToHost(const QHostAddress &address, quint16 port);
- bool connectToHostByName(const QString &name, quint16 port);
- bool bind(const QHostAddress &address, quint16 port);
- bool listen();
- int accept();
- void close();
+ bool connectToHost(const QHostAddress &address, quint16 port) Q_DECL_OVERRIDE;
+ bool connectToHostByName(const QString &name, quint16 port) Q_DECL_OVERRIDE;
+ bool bind(const QHostAddress &address, quint16 port) Q_DECL_OVERRIDE;
+ bool listen() Q_DECL_OVERRIDE;
+ int accept() Q_DECL_OVERRIDE;
+ void close() Q_DECL_OVERRIDE;
#ifndef QT_NO_NETWORKINTERFACE
bool joinMulticastGroup(const QHostAddress &groupAddress,
- const QNetworkInterface &iface);
+ const QNetworkInterface &iface) Q_DECL_OVERRIDE;
bool leaveMulticastGroup(const QHostAddress &groupAddress,
- const QNetworkInterface &iface);
- QNetworkInterface multicastInterface() const;
- bool setMulticastInterface(const QNetworkInterface &iface);
+ const QNetworkInterface &iface) Q_DECL_OVERRIDE;
+ QNetworkInterface multicastInterface() const Q_DECL_OVERRIDE;
+ bool setMulticastInterface(const QNetworkInterface &iface) Q_DECL_OVERRIDE;
#endif
- qint64 bytesAvailable() const;
+ qint64 bytesAvailable() const Q_DECL_OVERRIDE;
- qint64 read(char *data, qint64 maxlen);
- qint64 write(const char *data, qint64 len);
+ qint64 read(char *data, qint64 maxlen) Q_DECL_OVERRIDE;
+ qint64 write(const char *data, qint64 len) Q_DECL_OVERRIDE;
qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *addr = 0,
- quint16 *port = 0);
+ quint16 *port = 0) Q_DECL_OVERRIDE;
qint64 writeDatagram(const char *data, qint64 len, const QHostAddress &addr,
- quint16 port);
- bool hasPendingDatagrams() const;
- qint64 pendingDatagramSize() const;
+ quint16 port) Q_DECL_OVERRIDE;
+ bool hasPendingDatagrams() const Q_DECL_OVERRIDE;
+ qint64 pendingDatagramSize() const Q_DECL_OVERRIDE;
- qint64 bytesToWrite() const;
+ qint64 bytesToWrite() const Q_DECL_OVERRIDE;
qint64 receiveBufferSize() const;
void setReceiveBufferSize(qint64 bufferSize);
@@ -148,21 +148,21 @@ public:
qint64 sendBufferSize() const;
void setSendBufferSize(qint64 bufferSize);
- int option(SocketOption option) const;
- bool setOption(SocketOption option, int value);
+ int option(SocketOption option) const Q_DECL_OVERRIDE;
+ bool setOption(SocketOption option, int value) Q_DECL_OVERRIDE;
- bool waitForRead(int msecs = 30000, bool *timedOut = 0);
- bool waitForWrite(int msecs = 30000, bool *timedOut = 0);
+ bool waitForRead(int msecs = 30000, bool *timedOut = 0) Q_DECL_OVERRIDE;
+ bool waitForWrite(int msecs = 30000, bool *timedOut = 0) Q_DECL_OVERRIDE;
bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite,
bool checkRead, bool checkWrite,
- int msecs = 30000, bool *timedOut = 0);
+ int msecs = 30000, bool *timedOut = 0) Q_DECL_OVERRIDE;
- bool isReadNotificationEnabled() const;
- void setReadNotificationEnabled(bool enable);
- bool isWriteNotificationEnabled() const;
- void setWriteNotificationEnabled(bool enable);
- bool isExceptionNotificationEnabled() const;
- void setExceptionNotificationEnabled(bool enable);
+ bool isReadNotificationEnabled() const Q_DECL_OVERRIDE;
+ void setReadNotificationEnabled(bool enable) Q_DECL_OVERRIDE;
+ bool isWriteNotificationEnabled() const Q_DECL_OVERRIDE;
+ void setWriteNotificationEnabled(bool enable) Q_DECL_OVERRIDE;
+ bool isExceptionNotificationEnabled() const Q_DECL_OVERRIDE;
+ void setExceptionNotificationEnabled(bool enable) Q_DECL_OVERRIDE;
public Q_SLOTS:
// non-virtual override;
@@ -232,6 +232,7 @@ public:
};
void setError(QAbstractSocket::SocketError error, ErrorString errorString) const;
+ QHostAddress adjustAddressProtocol(const QHostAddress &address) const;
// native functions
int option(QNativeSocketEngine::SocketOption option) const;
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index a7534a2f3f..4648a3cb5a 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -1,7 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -127,6 +128,83 @@ static inline void qt_socket_getPortAndAddress(const qt_sockaddr *s, quint16 *po
}
}
+static inline uint makeScopeId(const QHostAddress &addr)
+{
+ QString scopeid = addr.scopeId();
+ if (scopeid.isEmpty())
+ return 0;
+
+ bool ok;
+ uint id = scopeid.toUInt(&ok);
+#ifndef QT_NO_IPV6IFNAME
+ if (!ok)
+ id = ::if_nametoindex(scopeid.toLatin1());
+#endif
+ return id;
+}
+
+static void convertToLevelAndOption(QNativeSocketEngine::SocketOption opt,
+ QAbstractSocket::NetworkLayerProtocol socketProtocol, int &level, int &n)
+{
+ n = -1;
+ level = SOL_SOCKET; // default
+
+ switch (opt) {
+ case QNativeSocketEngine::NonBlockingSocketOption: // fcntl, not setsockopt
+ case QNativeSocketEngine::BindExclusively: // not handled on Unix
+ Q_UNREACHABLE();
+
+ case QNativeSocketEngine::BroadcastSocketOption:
+ n = SO_BROADCAST;
+ break;
+ case QNativeSocketEngine::ReceiveBufferSocketOption:
+ n = SO_RCVBUF;
+ break;
+ case QNativeSocketEngine::SendBufferSocketOption:
+ n = SO_SNDBUF;
+ break;
+ case QNativeSocketEngine::AddressReusable:
+ n = SO_REUSEADDR;
+ break;
+ case QNativeSocketEngine::ReceiveOutOfBandData:
+ n = SO_OOBINLINE;
+ break;
+ case QNativeSocketEngine::LowDelayOption:
+ level = IPPROTO_TCP;
+ n = TCP_NODELAY;
+ break;
+ case QNativeSocketEngine::KeepAliveOption:
+ n = SO_KEEPALIVE;
+ break;
+ case QNativeSocketEngine::MulticastTtlOption:
+ if (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) {
+ level = IPPROTO_IPV6;
+ n = IPV6_MULTICAST_HOPS;
+ } else
+ {
+ level = IPPROTO_IP;
+ n = IP_MULTICAST_TTL;
+ }
+ break;
+ case QNativeSocketEngine::MulticastLoopbackOption:
+ if (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) {
+ level = IPPROTO_IPV6;
+ n = IPV6_MULTICAST_LOOP;
+ } else
+ {
+ level = IPPROTO_IP;
+ n = IP_MULTICAST_LOOP;
+ }
+ break;
+ case QNativeSocketEngine::TypeOfServiceOption:
+ if (socketProtocol == QAbstractSocket::IPv4Protocol) {
+ level = IPPROTO_IP;
+ n = IP_TOS;
+ }
+ break;
+ }
+}
+
/*! \internal
Creates and returns a new socket descriptor of type \a socketType
@@ -193,65 +271,16 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
if (!q->isValid())
return -1;
- int n = -1;
- int level = SOL_SOCKET; // default
-
- switch (opt) {
- case QNativeSocketEngine::ReceiveBufferSocketOption:
- n = SO_RCVBUF;
- break;
- case QNativeSocketEngine::SendBufferSocketOption:
- n = SO_SNDBUF;
- break;
- case QNativeSocketEngine::NonBlockingSocketOption:
- break;
- case QNativeSocketEngine::BroadcastSocketOption:
- break;
- case QNativeSocketEngine::AddressReusable:
- n = SO_REUSEADDR;
- break;
- case QNativeSocketEngine::BindExclusively:
+ // handle non-getsockopt cases first
+ if (opt == QNativeSocketEngine::BindExclusively || opt == QNativeSocketEngine::NonBlockingSocketOption
+ || opt == QNativeSocketEngine::BroadcastSocketOption)
return true;
- case QNativeSocketEngine::ReceiveOutOfBandData:
- n = SO_OOBINLINE;
- break;
- case QNativeSocketEngine::LowDelayOption:
- level = IPPROTO_TCP;
- n = TCP_NODELAY;
- break;
- case QNativeSocketEngine::KeepAliveOption:
- n = SO_KEEPALIVE;
- break;
- case QNativeSocketEngine::MulticastTtlOption:
- if (socketProtocol == QAbstractSocket::IPv6Protocol) {
- level = IPPROTO_IPV6;
- n = IPV6_MULTICAST_HOPS;
- } else
- {
- level = IPPROTO_IP;
- n = IP_MULTICAST_TTL;
- }
- break;
- case QNativeSocketEngine::MulticastLoopbackOption:
- if (socketProtocol == QAbstractSocket::IPv6Protocol) {
- level = IPPROTO_IPV6;
- n = IPV6_MULTICAST_LOOP;
- } else
- {
- level = IPPROTO_IP;
- n = IP_MULTICAST_LOOP;
- }
- break;
- case QNativeSocketEngine::TypeOfServiceOption:
- if (socketProtocol == QAbstractSocket::IPv4Protocol) {
- level = IPPROTO_IP;
- n = IP_TOS;
- }
- break;
- }
+ int n, level;
int v = -1;
QT_SOCKOPTLEN_T len = sizeof(v);
+
+ convertToLevelAndOption(opt, socketProtocol, level, n);
if (::getsockopt(socketDescriptor, level, n, (char *) &v, &len) != -1)
return v;
@@ -268,19 +297,8 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
if (!q->isValid())
return false;
- int n = 0;
- int level = SOL_SOCKET; // default
-
+ // handle non-setsockopt cases first
switch (opt) {
- case QNativeSocketEngine::ReceiveBufferSocketOption:
- n = SO_RCVBUF;
- break;
- case QNativeSocketEngine::SendBufferSocketOption:
- n = SO_SNDBUF;
- break;
- case QNativeSocketEngine::BroadcastSocketOption:
- n = SO_BROADCAST;
- break;
case QNativeSocketEngine::NonBlockingSocketOption: {
// Make the socket nonblocking.
#if !defined(Q_OS_VXWORKS)
@@ -310,58 +328,24 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
#endif // Q_OS_VXWORKS
return true;
}
- case QNativeSocketEngine::AddressReusable:
+ case QNativeSocketEngine::BindExclusively:
+ return true;
+
+ default:
+ break;
+ }
+
+ int n, level;
+ convertToLevelAndOption(opt, socketProtocol, level, n);
#if defined(SO_REUSEPORT)
+ if (opt == QNativeSocketEngine::AddressReusable) {
// on OS X, SO_REUSEADDR isn't sufficient to allow multiple binds to the
// same port (which is useful for multicast UDP). SO_REUSEPORT is, but
// we most definitely do not want to use this for TCP. See QTBUG-6305.
if (socketType == QAbstractSocket::UdpSocket)
n = SO_REUSEPORT;
- else
- n = SO_REUSEADDR;
-#else
- n = SO_REUSEADDR;
-#endif
- break;
- case QNativeSocketEngine::BindExclusively:
- return true;
- case QNativeSocketEngine::ReceiveOutOfBandData:
- n = SO_OOBINLINE;
- break;
- case QNativeSocketEngine::LowDelayOption:
- level = IPPROTO_TCP;
- n = TCP_NODELAY;
- break;
- case QNativeSocketEngine::KeepAliveOption:
- n = SO_KEEPALIVE;
- break;
- case QNativeSocketEngine::MulticastTtlOption:
- if (socketProtocol == QAbstractSocket::IPv6Protocol) {
- level = IPPROTO_IPV6;
- n = IPV6_MULTICAST_HOPS;
- } else
- {
- level = IPPROTO_IP;
- n = IP_MULTICAST_TTL;
- }
- break;
- case QNativeSocketEngine::MulticastLoopbackOption:
- if (socketProtocol == QAbstractSocket::IPv6Protocol) {
- level = IPPROTO_IPV6;
- n = IPV6_MULTICAST_LOOP;
- } else
- {
- level = IPPROTO_IP;
- n = IP_MULTICAST_LOOP;
- }
- break;
- case QNativeSocketEngine::TypeOfServiceOption:
- if (socketProtocol == QAbstractSocket::IPv4Protocol) {
- level = IPPROTO_IP;
- n = IP_TOS;
- }
- break;
}
+#endif
return ::setsockopt(socketDescriptor, level, n, (char *) &v, sizeof(v)) == 0;
}
@@ -382,17 +366,8 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16
memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
sockAddrIPv6.sin6_family = AF_INET6;
sockAddrIPv6.sin6_port = htons(port);
+ sockAddrIPv6.sin6_scope_id = makeScopeId(addr);
- QString scopeid = addr.scopeId();
-
- if (!scopeid.isEmpty()) {
- bool ok;
- sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok);
-#ifndef QT_NO_IPV6IFNAME
- if (!ok)
- sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1());
-#endif
- }
Q_IPV6ADDR ip6 = addr.toIPv6Address();
memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &ip6, sizeof(ip6));
@@ -501,16 +476,8 @@ bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &address, quint16
memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
sockAddrIPv6.sin6_family = AF_INET6;
sockAddrIPv6.sin6_port = htons(port);
- QString scopeid = address.scopeId();
+ sockAddrIPv6.sin6_scope_id = makeScopeId(address);
- if (!scopeid.isEmpty()) {
- bool ok;
- sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok);
-#ifndef QT_NO_IPV6IFNAME
- if (!ok)
- sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1());
-#endif
- }
Q_IPV6ADDR tmp = address.toIPv6Address();
memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &tmp, sizeof(tmp));
sockAddrSize = sizeof(sockAddrIPv6);
@@ -749,7 +716,7 @@ bool QNativeSocketEnginePrivate::nativeLeaveMulticastGroup(const QHostAddress &g
QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
{
- if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ if (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) {
uint v;
QT_SOCKOPTLEN_T sizeofv = sizeof(v);
if (::getsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, &v, &sizeofv) == -1)
@@ -779,7 +746,7 @@ QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
bool QNativeSocketEnginePrivate::nativeSetMulticastInterface(const QNetworkInterface &iface)
{
- if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ if (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) {
uint v = iface.index();
return (::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, &v, sizeof(v)) != -1);
}
@@ -918,19 +885,10 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
sockAddrIPv6.sin6_family = AF_INET6;
sockAddrIPv6.sin6_port = htons(port);
+ sockAddrIPv6.sin6_scope_id = makeScopeId(host);
Q_IPV6ADDR tmp = host.toIPv6Address();
memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &tmp, sizeof(tmp));
- QString scopeid = host.scopeId();
-
- if (!scopeid.isEmpty()) {
- bool ok;
- sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok);
-#ifndef QT_NO_IPV6IFNAME
- if (!ok)
- sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1());
-#endif
- }
sockAddrSize = sizeof(sockAddrIPv6);
sockAddrPtr = (struct sockaddr *)&sockAddrIPv6;
} else if (host.protocol() == QAbstractSocket::IPv4Protocol) {
@@ -1037,7 +995,7 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
#if defined (QNATIVESOCKETENGINE_DEBUG)
QString socketProtocolStr = QStringLiteral("UnknownProtocol");
if (socketProtocol == QAbstractSocket::IPv4Protocol) socketProtocolStr = QStringLiteral("IPv4Protocol");
- else if (socketProtocol == QAbstractSocket::IPv6Protocol) socketProtocolStr = QStringLiteral("IPv6Protocol");
+ else if (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) socketProtocolStr = QStringLiteral("IPv6Protocol");
QString socketTypeStr = QStringLiteral("UnknownSocketType");
if (socketType == QAbstractSocket::TcpSocket) socketTypeStr = QStringLiteral("TcpSocket");
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index 7d62fc3955..72f85c831f 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -1,7 +1,8 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Copyright (C) 2015 Intel Corporation.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +11,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +24,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -195,6 +196,64 @@ static inline void qt_socket_getPortAndAddress(SOCKET socketDescriptor, const qt
}
}
+static void convertToLevelAndOption(QNativeSocketEngine::SocketOption opt,
+ QAbstractSocket::NetworkLayerProtocol socketProtocol, int &level, int &n)
+{
+ n = 0;
+ level = SOL_SOCKET; // default
+
+ switch (opt) {
+ case QNativeSocketEngine::NonBlockingSocketOption: // WSAIoctl
+ case QNativeSocketEngine::TypeOfServiceOption: // not supported
+ Q_UNREACHABLE();
+
+ case QNativeSocketEngine::ReceiveBufferSocketOption:
+ n = SO_RCVBUF;
+ break;
+ case QNativeSocketEngine::SendBufferSocketOption:
+ n = SO_SNDBUF;
+ break;
+ case QNativeSocketEngine::BroadcastSocketOption:
+ n = SO_BROADCAST;
+ break;
+ case QNativeSocketEngine::AddressReusable:
+ n = SO_REUSEADDR;
+ break;
+ case QNativeSocketEngine::BindExclusively:
+ n = SO_EXCLUSIVEADDRUSE;
+ break;
+ case QNativeSocketEngine::ReceiveOutOfBandData:
+ n = SO_OOBINLINE;
+ break;
+ case QNativeSocketEngine::LowDelayOption:
+ level = IPPROTO_TCP;
+ n = TCP_NODELAY;
+ break;
+ case QNativeSocketEngine::KeepAliveOption:
+ n = SO_KEEPALIVE;
+ break;
+ case QNativeSocketEngine::MulticastTtlOption:
+ if (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) {
+ level = IPPROTO_IPV6;
+ n = IPV6_MULTICAST_HOPS;
+ } else
+ {
+ level = IPPROTO_IP;
+ n = IP_MULTICAST_TTL;
+ }
+ break;
+ case QNativeSocketEngine::MulticastLoopbackOption:
+ if (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) {
+ level = IPPROTO_IPV6;
+ n = IPV6_MULTICAST_LOOP;
+ } else
+ {
+ level = IPPROTO_IP;
+ n = IP_MULTICAST_LOOP;
+ }
+ break;
+ }
+}
/*! \internal
@@ -209,7 +268,7 @@ void QNativeSocketEnginePrivate::setPortAndAddress(sockaddr_in * sockAddrIPv4, q
|| socketProtocol == QAbstractSocket::AnyIPProtocol) {
memset(sockAddrIPv6, 0, sizeof(qt_sockaddr_in6));
sockAddrIPv6->sin6_family = AF_INET6;
- sockAddrIPv6->sin6_scope_id = address.scopeId().toInt();
+ sockAddrIPv6->sin6_scope_id = address.scopeId().toUInt();
WSAHtons(socketDescriptor, port, &(sockAddrIPv6->sin6_port));
Q_IPV6ADDR tmp = address.toIPv6Address();
memcpy(&(sockAddrIPv6->sin6_addr.qt_s6_addr), &tmp, sizeof(tmp));
@@ -404,19 +463,8 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
if (!q->isValid())
return -1;
- int n = -1;
- int level = SOL_SOCKET; // default
-
+ // handle non-getsockopt
switch (opt) {
- case QNativeSocketEngine::ReceiveBufferSocketOption:
- n = SO_RCVBUF;
- break;
- case QNativeSocketEngine::SendBufferSocketOption:
- n = SO_SNDBUF;
- break;
- case QNativeSocketEngine::BroadcastSocketOption:
- n = SO_BROADCAST;
- break;
case QNativeSocketEngine::NonBlockingSocketOption: {
unsigned long buf = 0;
if (WSAIoctl(socketDescriptor, FIONBIO, 0,0, &buf, sizeof(buf), 0,0,0) == 0)
@@ -425,53 +473,21 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
return -1;
break;
}
- case QNativeSocketEngine::AddressReusable:
- n = SO_REUSEADDR;
- break;
- case QNativeSocketEngine::BindExclusively:
- n = SO_EXCLUSIVEADDRUSE;
- break;
- case QNativeSocketEngine::ReceiveOutOfBandData:
- n = SO_OOBINLINE;
- break;
- case QNativeSocketEngine::LowDelayOption:
- level = IPPROTO_TCP;
- n = TCP_NODELAY;
- break;
- case QNativeSocketEngine::KeepAliveOption:
- n = SO_KEEPALIVE;
- break;
- case QNativeSocketEngine::MulticastTtlOption:
-
- if (socketProtocol == QAbstractSocket::IPv6Protocol) {
- level = IPPROTO_IPV6;
- n = IPV6_MULTICAST_HOPS;
- } else
- {
- level = IPPROTO_IP;
- n = IP_MULTICAST_TTL;
- }
- break;
- case QNativeSocketEngine::MulticastLoopbackOption:
- if (socketProtocol == QAbstractSocket::IPv6Protocol) {
- level = IPPROTO_IPV6;
- n = IPV6_MULTICAST_LOOP;
- } else
- {
- level = IPPROTO_IP;
- n = IP_MULTICAST_LOOP;
- }
- break;
case QNativeSocketEngine::TypeOfServiceOption:
return -1;
+
+ default:
break;
}
#if Q_BYTE_ORDER != Q_LITTLE_ENDIAN
#error code assumes windows is little endian
#endif
+ int n, level;
int v = 0; //note: windows doesn't write to all bytes if the option type is smaller than int
QT_SOCKOPTLEN_T len = sizeof(v);
+
+ convertToLevelAndOption(opt, socketProtocol, level, n);
if (getsockopt(socketDescriptor, level, n, (char *) &v, &len) == 0)
return v;
WS_ERROR_DEBUG(WSAGetLastError());
@@ -488,21 +504,12 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
if (!q->isValid())
return false;
- int n = 0;
- int level = SOL_SOCKET; // default
-
+ // handle non-setsockopt options
switch (opt) {
- case QNativeSocketEngine::ReceiveBufferSocketOption:
- n = SO_RCVBUF;
- break;
case QNativeSocketEngine::SendBufferSocketOption:
// see QTBUG-30478 SO_SNDBUF should not be used on Vista or later
if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA)
return false;
- n = SO_SNDBUF;
- break;
- case QNativeSocketEngine::BroadcastSocketOption:
- n = SO_BROADCAST;
break;
case QNativeSocketEngine::NonBlockingSocketOption:
{
@@ -516,47 +523,15 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
return true;
break;
}
- case QNativeSocketEngine::AddressReusable:
- n = SO_REUSEADDR;
- break;
- case QNativeSocketEngine::BindExclusively:
- n = SO_EXCLUSIVEADDRUSE;
- break;
- case QNativeSocketEngine::ReceiveOutOfBandData:
- n = SO_OOBINLINE;
- break;
- case QNativeSocketEngine::LowDelayOption:
- level = IPPROTO_TCP;
- n = TCP_NODELAY;
- break;
- case QNativeSocketEngine::KeepAliveOption:
- n = SO_KEEPALIVE;
- break;
- case QNativeSocketEngine::MulticastTtlOption:
- if (socketProtocol == QAbstractSocket::IPv6Protocol) {
- level = IPPROTO_IPV6;
- n = IPV6_MULTICAST_HOPS;
- } else
- {
- level = IPPROTO_IP;
- n = IP_MULTICAST_TTL;
- }
- break;
- case QNativeSocketEngine::MulticastLoopbackOption:
- if (socketProtocol == QAbstractSocket::IPv6Protocol) {
- level = IPPROTO_IPV6;
- n = IPV6_MULTICAST_LOOP;
- } else
- {
- level = IPPROTO_IP;
- n = IP_MULTICAST_LOOP;
- }
- break;
case QNativeSocketEngine::TypeOfServiceOption:
return false;
+
+ default:
break;
}
+ int n, level;
+ convertToLevelAndOption(opt, socketProtocol, level, n);
if (::setsockopt(socketDescriptor, level, n, (char*)&v, sizeof(v)) != 0) {
WS_ERROR_DEBUG(WSAGetLastError());
return false;
@@ -658,7 +633,7 @@ bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &address, quin
setPortAndAddress(&sockAddrIPv4, &sockAddrIPv6, port, address, &sockAddrPtr, &sockAddrSize);
- if (socketProtocol == QAbstractSocket::IPv6Protocol && address.toIPv4Address()) {
+ if ((socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) && address.toIPv4Address()) {
//IPV6_V6ONLY option must be cleared to connect to a V4 mapped address
if (QSysInfo::windowsVersion() >= QSysInfo::WV_6_0) {
DWORD ipv6only = 0;
@@ -1035,7 +1010,7 @@ bool QNativeSocketEnginePrivate::nativeLeaveMulticastGroup(const QHostAddress &g
QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
{
- if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ if (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) {
uint v;
QT_SOCKOPTLEN_T sizeofv = sizeof(v);
if (::getsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, (char *) &v, &sizeofv) == -1)
@@ -1069,7 +1044,7 @@ QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const
bool QNativeSocketEnginePrivate::nativeSetMulticastInterface(const QNetworkInterface &iface)
{
- if (socketProtocol == QAbstractSocket::IPv6Protocol) {
+ if (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) {
uint v = iface.isValid() ? iface.index() : 0;
return (::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, (char *) &v, sizeof(v)) != -1);
}
diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp
index c49eda179a..5c615034fc 100644
--- a/src/network/socket/qnativesocketengine_winrt.cpp
+++ b/src/network/socket/qnativesocketengine_winrt.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -163,6 +163,29 @@ static AsyncStatus opStatus(const ComPtr<T> &op)
return status;
}
+static qint64 writeIOStream(ComPtr<IOutputStream> stream, const char *data, qint64 len)
+{
+ ComPtr<IBuffer> buffer;
+ HRESULT hr = g->bufferFactory->Create(len, &buffer);
+ Q_ASSERT_SUCCEEDED(hr);
+ hr = buffer->put_Length(len);
+ Q_ASSERT_SUCCEEDED(hr);
+ ComPtr<Windows::Storage::Streams::IBufferByteAccess> byteArrayAccess;
+ hr = buffer.As(&byteArrayAccess);
+ Q_ASSERT_SUCCEEDED(hr);
+ byte *bytes;
+ hr = byteArrayAccess->Buffer(&bytes);
+ Q_ASSERT_SUCCEEDED(hr);
+ memcpy(bytes, data, len);
+ ComPtr<IAsyncOperationWithProgress<UINT32, UINT32>> op;
+ hr = stream->WriteAsync(buffer.Get(), &op);
+ RETURN_IF_FAILED("Failed to write to stream", return -1);
+ UINT32 bytesWritten;
+ hr = QWinRTFunctions::await(op, &bytesWritten);
+ RETURN_IF_FAILED("Failed to write to stream", return -1);
+ return bytesWritten;
+}
+
QNativeSocketEngine::QNativeSocketEngine(QObject *parent)
: QAbstractSocketEngine(*new QNativeSocketEnginePrivate(), parent)
{
@@ -492,35 +515,12 @@ qint64 QNativeSocketEngine::write(const char *data, qint64 len)
hr = d->tcpSocket()->get_OutputStream(&stream);
else if (d->socketType == QAbstractSocket::UdpSocket)
hr = d->udpSocket()->get_OutputStream(&stream);
- if (FAILED(hr)) {
- qErrnoWarning(hr, "Failed to get output stream to socket.");
- return -1;
- }
-
- ComPtr<IBuffer> buffer;
- hr = g->bufferFactory->Create(len, &buffer);
- Q_ASSERT_SUCCEEDED(hr);
- hr = buffer->put_Length(len);
- Q_ASSERT_SUCCEEDED(hr);
- ComPtr<Windows::Storage::Streams::IBufferByteAccess> byteArrayAccess;
- hr = buffer.As(&byteArrayAccess);
- Q_ASSERT_SUCCEEDED(hr);
- byte *bytes;
- hr = byteArrayAccess->Buffer(&bytes);
- Q_ASSERT_SUCCEEDED(hr);
- memcpy(bytes, data, len);
- ComPtr<IAsyncOperationWithProgress<UINT32, UINT32>> op;
- hr = stream->WriteAsync(buffer.Get(), &op);
- RETURN_IF_FAILED("Failed to write to stream", return -1);
+ RETURN_IF_FAILED("Failed to get output stream to socket", return -1);
- UINT32 bytesWritten;
- hr = QWinRTFunctions::await(op, &bytesWritten);
- if (FAILED(hr)) {
+ qint64 bytesWritten = writeIOStream(stream, data, len);
+ if (bytesWritten < 0)
d->setError(QAbstractSocket::SocketAccessError, QNativeSocketEnginePrivate::AccessErrorString);
- return -1;
- }
-
- if (bytesWritten && d->notifyOnWrite)
+ else if (bytesWritten > 0 && d->notifyOnWrite)
emit writeReady();
return bytesWritten;
@@ -560,11 +560,10 @@ qint64 QNativeSocketEngine::writeDatagram(const char *data, qint64 len, const QH
ComPtr<IHostName> remoteHost;
ComPtr<IHostNameFactory> hostNameFactory;
- if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_HostName).Get(),
- &hostNameFactory))) {
- qWarning("QNativeSocketEnginePrivate::nativeSendDatagram: could not obtain hostname factory");
- return -1;
- }
+
+ HRESULT hr = GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Networking_HostName).Get(),
+ &hostNameFactory);
+ RETURN_IF_FAILED("Could not obtain hostname factory", return -1);
const QString addressString = addr.toString();
HStringReference hostNameRef(reinterpret_cast<LPCWSTR>(addressString.utf16()));
hostNameFactory->CreateHostName(hostNameRef.Get(), &remoteHost);
@@ -573,17 +572,13 @@ qint64 QNativeSocketEngine::writeDatagram(const char *data, qint64 len, const QH
ComPtr<IOutputStream> stream;
const QString portString = QString::number(port);
HStringReference portRef(reinterpret_cast<LPCWSTR>(portString.utf16()));
- if (FAILED(d->udpSocket()->GetOutputStreamAsync(remoteHost.Get(), portRef.Get(), &streamOperation)))
- return -1;
- HRESULT hr;
- while (hr = streamOperation->GetResults(&stream) == E_ILLEGAL_METHOD_CALL)
- QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
- ComPtr<IDataWriterFactory> dataWriterFactory;
- GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_Streams_DataWriter).Get(), &dataWriterFactory);
- ComPtr<IDataWriter> writer;
- dataWriterFactory->CreateDataWriter(stream.Get(), &writer);
- writer->WriteBytes(len, (unsigned char *)data);
- return len;
+ hr = d->udpSocket()->GetOutputStreamAsync(remoteHost.Get(), portRef.Get(), &streamOperation);
+ RETURN_IF_FAILED("Failed to get output stream to socket", return -1);
+
+ hr = QWinRTFunctions::await(streamOperation, stream.GetAddressOf());
+ RETURN_IF_FAILED("Failed to get output stream to socket", return -1);
+
+ return writeIOStream(stream, data, len);
}
bool QNativeSocketEngine::hasPendingDatagrams() const
diff --git a/src/network/socket/qnativesocketengine_winrt_p.h b/src/network/socket/qnativesocketengine_winrt_p.h
index 716403097d..42920c96f2 100644
--- a/src/network/socket/qnativesocketengine_winrt_p.h
+++ b/src/network/socket/qnativesocketengine_winrt_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -46,6 +46,7 @@
//
#include <QtCore/QEventLoop>
#include <QtCore/QBuffer>
+#include <QtCore/QMutex>
#include "QtNetwork/qhostaddress.h"
#include "private/qabstractsocketengine_p.h"
#include <wrl.h>
diff --git a/src/network/socket/qnet_unix_p.h b/src/network/socket/qnet_unix_p.h
index ac4eef3bbe..979afb82ba 100644
--- a/src/network/socket/qnet_unix_p.h
+++ b/src/network/socket/qnet_unix_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp
index 60f1c2fa50..a6eafd2601 100644
--- a/src/network/socket/qsocks5socketengine.cpp
+++ b/src/network/socket/qsocks5socketengine.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -319,7 +319,7 @@ public:
QSocks5BindData *retrieve(qintptr socketDescriptor);
protected:
- void timerEvent(QTimerEvent * event);
+ void timerEvent(QTimerEvent * event) Q_DECL_OVERRIDE;
QMutex mutex;
int sweepTimerId;
@@ -426,13 +426,13 @@ bool QSocks5Authenticator::continueAuthenticate(QTcpSocket *socket, bool *comple
return true;
}
-bool QSocks5Authenticator::seal(const QByteArray buf, QByteArray *sealedBuf)
+bool QSocks5Authenticator::seal(const QByteArray &buf, QByteArray *sealedBuf)
{
*sealedBuf = buf;
return true;
}
-bool QSocks5Authenticator::unSeal(const QByteArray sealedBuf, QByteArray *buf)
+bool QSocks5Authenticator::unSeal(const QByteArray &sealedBuf, QByteArray *buf)
{
*buf = sealedBuf;
return true;
diff --git a/src/network/socket/qsocks5socketengine_p.h b/src/network/socket/qsocks5socketengine_p.h
index fd6e187b98..c97b0e89ce 100644
--- a/src/network/socket/qsocks5socketengine_p.h
+++ b/src/network/socket/qsocks5socketengine_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -61,63 +61,63 @@ public:
QSocks5SocketEngine(QObject *parent = 0);
~QSocks5SocketEngine();
- bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol);
- bool initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState);
+ bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol) Q_DECL_OVERRIDE;
+ bool initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState) Q_DECL_OVERRIDE;
void setProxy(const QNetworkProxy &networkProxy);
- qintptr socketDescriptor() const;
+ qintptr socketDescriptor() const Q_DECL_OVERRIDE;
- bool isValid() const;
+ bool isValid() const Q_DECL_OVERRIDE;
bool connectInternal();
- bool connectToHost(const QHostAddress &address, quint16 port);
- bool connectToHostByName(const QString &name, quint16 port);
- bool bind(const QHostAddress &address, quint16 port);
- bool listen();
- int accept();
- void close();
+ bool connectToHost(const QHostAddress &address, quint16 port) Q_DECL_OVERRIDE;
+ bool connectToHostByName(const QString &name, quint16 port) Q_DECL_OVERRIDE;
+ bool bind(const QHostAddress &address, quint16 port) Q_DECL_OVERRIDE;
+ bool listen() Q_DECL_OVERRIDE;
+ int accept() Q_DECL_OVERRIDE;
+ void close() Q_DECL_OVERRIDE;
- qint64 bytesAvailable() const;
+ qint64 bytesAvailable() const Q_DECL_OVERRIDE;
- qint64 read(char *data, qint64 maxlen);
- qint64 write(const char *data, qint64 len);
+ qint64 read(char *data, qint64 maxlen) Q_DECL_OVERRIDE;
+ qint64 write(const char *data, qint64 len) Q_DECL_OVERRIDE;
#ifndef QT_NO_UDPSOCKET
#ifndef QT_NO_NETWORKINTERFACE
bool joinMulticastGroup(const QHostAddress &groupAddress,
- const QNetworkInterface &interface);
+ const QNetworkInterface &interface) Q_DECL_OVERRIDE;
bool leaveMulticastGroup(const QHostAddress &groupAddress,
- const QNetworkInterface &interface);
- QNetworkInterface multicastInterface() const;
- bool setMulticastInterface(const QNetworkInterface &iface);
+ const QNetworkInterface &interface) Q_DECL_OVERRIDE;
+ QNetworkInterface multicastInterface() const Q_DECL_OVERRIDE;
+ bool setMulticastInterface(const QNetworkInterface &iface) Q_DECL_OVERRIDE;
#endif // QT_NO_NETWORKINTERFACE
qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *addr = 0,
- quint16 *port = 0);
+ quint16 *port = 0) Q_DECL_OVERRIDE;
qint64 writeDatagram(const char *data, qint64 len, const QHostAddress &addr,
- quint16 port);
- bool hasPendingDatagrams() const;
- qint64 pendingDatagramSize() const;
+ quint16 port) Q_DECL_OVERRIDE;
+ bool hasPendingDatagrams() const Q_DECL_OVERRIDE;
+ qint64 pendingDatagramSize() const Q_DECL_OVERRIDE;
#endif // QT_NO_UDPSOCKET
- qint64 bytesToWrite() const;
+ qint64 bytesToWrite() const Q_DECL_OVERRIDE;
- int option(SocketOption option) const;
- bool setOption(SocketOption option, int value);
+ int option(SocketOption option) const Q_DECL_OVERRIDE;
+ bool setOption(SocketOption option, int value) Q_DECL_OVERRIDE;
- bool waitForRead(int msecs = 30000, bool *timedOut = 0);
- bool waitForWrite(int msecs = 30000, bool *timedOut = 0);
+ bool waitForRead(int msecs = 30000, bool *timedOut = 0) Q_DECL_OVERRIDE;
+ bool waitForWrite(int msecs = 30000, bool *timedOut = 0) Q_DECL_OVERRIDE;
bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite,
bool checkRead, bool checkWrite,
- int msecs = 30000, bool *timedOut = 0);
+ int msecs = 30000, bool *timedOut = 0) Q_DECL_OVERRIDE;
- bool isReadNotificationEnabled() const;
- void setReadNotificationEnabled(bool enable);
- bool isWriteNotificationEnabled() const;
- void setWriteNotificationEnabled(bool enable);
- bool isExceptionNotificationEnabled() const;
- void setExceptionNotificationEnabled(bool enable);
+ bool isReadNotificationEnabled() const Q_DECL_OVERRIDE;
+ void setReadNotificationEnabled(bool enable) Q_DECL_OVERRIDE;
+ bool isWriteNotificationEnabled() const Q_DECL_OVERRIDE;
+ void setWriteNotificationEnabled(bool enable) Q_DECL_OVERRIDE;
+ bool isExceptionNotificationEnabled() const Q_DECL_OVERRIDE;
+ void setExceptionNotificationEnabled(bool enable) Q_DECL_OVERRIDE;
private:
Q_DECLARE_PRIVATE(QSocks5SocketEngine)
@@ -149,8 +149,8 @@ public:
virtual bool beginAuthenticate(QTcpSocket *socket, bool *completed);
virtual bool continueAuthenticate(QTcpSocket *socket, bool *completed);
- virtual bool seal(const QByteArray buf, QByteArray *sealedBuf);
- virtual bool unSeal(const QByteArray sealedBuf, QByteArray *buf);
+ virtual bool seal(const QByteArray &buf, QByteArray *sealedBuf);
+ virtual bool unSeal(const QByteArray &sealedBuf, QByteArray *buf);
virtual bool unSeal(QTcpSocket *sealedSocket, QByteArray *buf);
virtual QString errorString() { return QString(); }
@@ -160,11 +160,11 @@ class QSocks5PasswordAuthenticator : public QSocks5Authenticator
{
public:
QSocks5PasswordAuthenticator(const QString &userName, const QString &password);
- char methodId();
- bool beginAuthenticate(QTcpSocket *socket, bool *completed);
- bool continueAuthenticate(QTcpSocket *socket, bool *completed);
+ char methodId() Q_DECL_OVERRIDE;
+ bool beginAuthenticate(QTcpSocket *socket, bool *completed) Q_DECL_OVERRIDE;
+ bool continueAuthenticate(QTcpSocket *socket, bool *completed) Q_DECL_OVERRIDE;
- QString errorString();
+ QString errorString() Q_DECL_OVERRIDE;
private:
QString userName;
@@ -282,8 +282,8 @@ class Q_AUTOTEST_EXPORT QSocks5SocketEngineHandler : public QSocketEngineHandler
{
public:
virtual QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType,
- const QNetworkProxy &, QObject *parent);
- virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescriptor, QObject *parent);
+ const QNetworkProxy &, QObject *parent) Q_DECL_OVERRIDE;
+ virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescriptor, QObject *parent) Q_DECL_OVERRIDE;
};
diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp
index ad3d529a3e..b41d207947 100644
--- a/src/network/socket/qtcpserver.cpp
+++ b/src/network/socket/qtcpserver.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -92,7 +92,8 @@
*/
#include "qtcpserver.h"
-#include "private/qobject_p.h"
+#include "qtcpserver_p.h"
+
#include "qalgorithms.h"
#include "qhostaddress.h"
#include "qlist.h"
@@ -108,43 +109,6 @@ QT_BEGIN_NAMESPACE
return returnValue; \
} } while (0)
-class QTcpServerPrivate : public QObjectPrivate, public QAbstractSocketEngineReceiver
-{
- Q_DECLARE_PUBLIC(QTcpServer)
-public:
- QTcpServerPrivate();
- ~QTcpServerPrivate();
-
- QList<QTcpSocket *> pendingConnections;
-
- quint16 port;
- QHostAddress address;
-
- QAbstractSocket::SocketState state;
- QAbstractSocketEngine *socketEngine;
-
- QAbstractSocket::SocketError serverSocketError;
- QString serverSocketErrorString;
-
- int maxConnections;
-
-#ifndef QT_NO_NETWORKPROXY
- QNetworkProxy proxy;
- QNetworkProxy resolveProxy(const QHostAddress &address, quint16 port);
-#endif
-
- // from QAbstractSocketEngineReceiver
- void readNotification();
- void closeNotification() { readNotification(); }
- inline void writeNotification() {}
- inline void exceptionNotification() {}
- inline void connectionNotification() {}
-#ifndef QT_NO_NETWORKPROXY
- inline void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *) {}
-#endif
-
-};
-
/*! \internal
*/
QTcpServerPrivate::QTcpServerPrivate()
@@ -257,6 +221,13 @@ QTcpServer::~QTcpServer()
close();
}
+/*! \internal
+*/
+QTcpServer::QTcpServer(QTcpServerPrivate &dd, QObject *parent)
+ : QObject(dd, parent)
+{
+}
+
/*!
Tells the server to listen for incoming connections on address \a
address and port \a port. If \a port is 0, a port is chosen
diff --git a/src/network/socket/qtcpserver.h b/src/network/socket/qtcpserver.h
index 2098a3b97d..8c7537a9b1 100644
--- a/src/network/socket/qtcpserver.h
+++ b/src/network/socket/qtcpserver.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
@@ -87,6 +87,8 @@ protected:
virtual void incomingConnection(qintptr handle);
void addPendingConnection(QTcpSocket* socket);
+ QTcpServer(QTcpServerPrivate &dd, QObject *parent = 0);
+
Q_SIGNALS:
void newConnection();
void acceptError(QAbstractSocket::SocketError socketError);
diff --git a/src/network/socket/qtcpserver_p.h b/src/network/socket/qtcpserver_p.h
new file mode 100644
index 0000000000..415a0e190a
--- /dev/null
+++ b/src/network/socket/qtcpserver_p.h
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtNetwork module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL21$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QTCPSERVER_P_H
+#define QTCPSERVER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of the QLibrary class. This header file may change from
+// version to version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "QtNetwork/qtcpserver.h"
+#include "private/qobject_p.h"
+#include "private/qabstractsocketengine_p.h"
+#include "QtNetwork/qabstractsocket.h"
+#include "qnetworkproxy.h"
+#include "QtCore/qlist.h"
+#include "qhostaddress.h"
+
+QT_BEGIN_NAMESPACE
+
+class QTcpServerPrivate : public QObjectPrivate, public QAbstractSocketEngineReceiver
+{
+ Q_DECLARE_PUBLIC(QTcpServer)
+public:
+ QTcpServerPrivate();
+ ~QTcpServerPrivate();
+
+ QList<QTcpSocket *> pendingConnections;
+
+ quint16 port;
+ QHostAddress address;
+
+ QAbstractSocket::SocketState state;
+ QAbstractSocketEngine *socketEngine;
+
+ QAbstractSocket::SocketError serverSocketError;
+ QString serverSocketErrorString;
+
+ int maxConnections;
+
+#ifndef QT_NO_NETWORKPROXY
+ QNetworkProxy proxy;
+ QNetworkProxy resolveProxy(const QHostAddress &address, quint16 port);
+#endif
+
+ // from QAbstractSocketEngineReceiver
+ void readNotification() Q_DECL_OVERRIDE;
+ void closeNotification() Q_DECL_OVERRIDE { readNotification(); }
+ void writeNotification() Q_DECL_OVERRIDE {}
+ void exceptionNotification() Q_DECL_OVERRIDE {}
+ void connectionNotification() Q_DECL_OVERRIDE {}
+#ifndef QT_NO_NETWORKPROXY
+ void proxyAuthenticationRequired(const QNetworkProxy &, QAuthenticator *) Q_DECL_OVERRIDE {}
+#endif
+
+};
+
+QT_END_NAMESPACE
+
+#endif // QTCPSERVER_P_H
diff --git a/src/network/socket/qtcpsocket.cpp b/src/network/socket/qtcpsocket.cpp
index 6aef8d9a2e..b6072b2909 100644
--- a/src/network/socket/qtcpsocket.cpp
+++ b/src/network/socket/qtcpsocket.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qtcpsocket.h b/src/network/socket/qtcpsocket.h
index ea1765284b..3449beeceb 100644
--- a/src/network/socket/qtcpsocket.h
+++ b/src/network/socket/qtcpsocket.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qtcpsocket_p.h b/src/network/socket/qtcpsocket_p.h
index a652eab190..85bf9cf806 100644
--- a/src/network/socket/qtcpsocket_p.h
+++ b/src/network/socket/qtcpsocket_p.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qudpsocket.cpp b/src/network/socket/qudpsocket.cpp
index b54ff96200..87686f94e1 100644
--- a/src/network/socket/qudpsocket.cpp
+++ b/src/network/socket/qudpsocket.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/qudpsocket.h b/src/network/socket/qudpsocket.h
index 92e520a899..fcf16fb345 100644
--- a/src/network/socket/qudpsocket.h
+++ b/src/network/socket/qudpsocket.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtNetwork module of the Qt Toolkit.
**
@@ -10,9 +10,9 @@
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see http://www.qt.io/terms-conditions. For further
+** information use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -23,8 +23,8 @@
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
+** As a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** $QT_END_LICENSE$
diff --git a/src/network/socket/socket.pri b/src/network/socket/socket.pri
index 7e3a54e303..3fb85160ea 100644
--- a/src/network/socket/socket.pri
+++ b/src/network/socket/socket.pri
@@ -12,7 +12,8 @@ HEADERS += socket/qabstractsocketengine_p.h \
socket/qlocalserver.h \
socket/qlocalserver_p.h \
socket/qlocalsocket.h \
- socket/qlocalsocket_p.h
+ socket/qlocalsocket_p.h \
+ socket/qtcpserver_p.h
SOURCES += socket/qabstractsocketengine.cpp \
socket/qhttpsocketengine.cpp \