diff options
Diffstat (limited to 'src/network/socket')
-rw-r--r-- | src/network/socket/qabstractsocket.cpp | 37 | ||||
-rw-r--r-- | src/network/socket/qabstractsocket.h | 4 | ||||
-rw-r--r-- | src/network/socket/qabstractsocketengine.cpp | 4 | ||||
-rw-r--r-- | src/network/socket/qabstractsocketengine_p.h | 2 | ||||
-rw-r--r-- | src/network/socket/qlocalserver.cpp | 2 | ||||
-rw-r--r-- | src/network/socket/qnativesocketengine_p.h | 6 | ||||
-rw-r--r-- | src/network/socket/qnativesocketengine_unix.cpp | 2 | ||||
-rw-r--r-- | src/network/socket/qnativesocketengine_win.cpp | 28 | ||||
-rw-r--r-- | src/network/socket/qnativesocketengine_winrt.cpp | 327 | ||||
-rw-r--r-- | src/network/socket/qnativesocketengine_winrt_p.h | 145 | ||||
-rw-r--r-- | src/network/socket/qsocks5socketengine.cpp | 7 | ||||
-rw-r--r-- | src/network/socket/socket.pri | 19 |
12 files changed, 551 insertions, 32 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index e0e13205fd..1906166257 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -372,9 +372,22 @@ IP_MULTICAST_LOOP (multicast loopback) socket option. \value TypeOfServiceOption This option is not supported on - Windows. This maps to the IP_TOS socket option. + Windows. This maps to the IP_TOS socket option. For possible values, + see table below. - Possible values for the \e{TypeOfServiceOption} are: + \value SendBufferSizeSocketOption Sets the socket send buffer size + in bytes at the OS level. This maps to the SO_SNDBUF socket option. + This option does not affect the QIODevice or QAbstractSocket buffers. + This enum value has been introduced in Qt 5.3. + + \value ReceiveBufferSizeSocketOption Sets the socket receive + buffer size in bytes at the OS level. + This maps to the SO_RCVBUF socket option. + This option does not affect the QIODevice or QAbstractSocket buffers + (see \l{QAbstractSocket::}{setReadBufferSize()}). + This enum value has been introduced in Qt 5.3. + + Possible values for \e{TypeOfServiceOption} are: \table \header \li Value \li Description @@ -735,8 +748,8 @@ bool QAbstractSocketPrivate::canReadNotification() return true; } - if (!hasData && socketEngine) - socketEngine->setReadNotificationEnabled(true); + if (isBuffered && socketEngine) + socketEngine->setReadNotificationEnabled(readBufferMaxSize == 0 || readBufferMaxSize > q->bytesAvailable()); // reset the read socket notifier state if we reentered inside the // readyRead() connected slot. @@ -1904,6 +1917,14 @@ void QAbstractSocket::setSocketOption(QAbstractSocket::SocketOption option, cons case TypeOfServiceOption: d_func()->socketEngine->setOption(QAbstractSocketEngine::TypeOfServiceOption, value.toInt()); break; + + case SendBufferSizeSocketOption: + d_func()->socketEngine->setOption(QAbstractSocketEngine::SendBufferSocketOption, value.toInt()); + break; + + case ReceiveBufferSizeSocketOption: + d_func()->socketEngine->setOption(QAbstractSocketEngine::ReceiveBufferSocketOption, value.toInt()); + break; } } @@ -1938,6 +1959,14 @@ QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option) case TypeOfServiceOption: ret = d_func()->socketEngine->option(QAbstractSocketEngine::TypeOfServiceOption); break; + + case SendBufferSizeSocketOption: + ret = d_func()->socketEngine->option(QAbstractSocketEngine::SendBufferSocketOption); + break; + + case ReceiveBufferSizeSocketOption: + ret = d_func()->socketEngine->option(QAbstractSocketEngine::ReceiveBufferSocketOption); + break; } if (ret == -1) return QVariant(); diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h index 46114abf73..8b019cf0fb 100644 --- a/src/network/socket/qabstractsocket.h +++ b/src/network/socket/qabstractsocket.h @@ -115,7 +115,9 @@ public: KeepAliveOption, // SO_KEEPALIVE MulticastTtlOption, // IP_MULTICAST_TTL MulticastLoopbackOption, // IP_MULTICAST_LOOPBACK - TypeOfServiceOption //IP_TOS + TypeOfServiceOption, //IP_TOS + SendBufferSizeSocketOption, //SO_SNDBUF + ReceiveBufferSizeSocketOption //SO_RCVBUF }; enum BindFlag { DefaultForPlatform = 0x0, diff --git a/src/network/socket/qabstractsocketengine.cpp b/src/network/socket/qabstractsocketengine.cpp index 1275461d7d..d8abe01241 100644 --- a/src/network/socket/qabstractsocketengine.cpp +++ b/src/network/socket/qabstractsocketengine.cpp @@ -41,7 +41,11 @@ #include "qabstractsocketengine_p.h" +#ifndef Q_OS_WINRT #include "qnativesocketengine_p.h" +#else +#include "qnativesocketengine_winrt_p.h" +#endif #include "qmutex.h" #include "qnetworkproxy.h" diff --git a/src/network/socket/qabstractsocketengine_p.h b/src/network/socket/qabstractsocketengine_p.h index 1dec96762c..6a30012562 100644 --- a/src/network/socket/qabstractsocketengine_p.h +++ b/src/network/socket/qabstractsocketengine_p.h @@ -150,7 +150,7 @@ public: virtual bool waitForRead(int msecs = 30000, bool *timedOut = 0) = 0; virtual bool waitForWrite(int msecs = 30000, bool *timedOut = 0) = 0; virtual bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, - bool checkRead, bool checkWrite, + bool checkRead, bool checkWrite, int msecs = 30000, bool *timedOut = 0) = 0; QAbstractSocket::SocketError error() const; diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp index f7f8aab182..791227002d 100644 --- a/src/network/socket/qlocalserver.cpp +++ b/src/network/socket/qlocalserver.cpp @@ -131,7 +131,7 @@ QLocalServer::QLocalServer(QObject *parent) QLocalServer::~QLocalServer() { if (isListening()) - close(); + close(); } /*! diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h index 97a9b98c30..fc1afa48c9 100644 --- a/src/network/socket/qnativesocketengine_p.h +++ b/src/network/socket/qnativesocketengine_p.h @@ -162,8 +162,8 @@ public: bool waitForRead(int msecs = 30000, bool *timedOut = 0); bool waitForWrite(int msecs = 30000, bool *timedOut = 0); bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, - bool checkRead, bool checkWrite, - int msecs = 30000, bool *timedOut = 0); + bool checkRead, bool checkWrite, + int msecs = 30000, bool *timedOut = 0); bool isReadNotificationEnabled() const; void setReadNotificationEnabled(bool enable); @@ -271,7 +271,7 @@ public: qint64 nativeWrite(const char *data, qint64 length); int nativeSelect(int timeout, bool selectForRead) const; int nativeSelect(int timeout, bool checkRead, bool checkWrite, - bool *selectForRead, bool *selectForWrite) const; + bool *selectForRead, bool *selectForWrite) const; #ifdef Q_OS_WIN void setPortAndAddress(sockaddr_in * sockAddrIPv4, qt_sockaddr_in6 * sockAddrIPv6, quint16 port, const QHostAddress & address, sockaddr ** sockAddrPtr, QT_SOCKLEN_T *sockAddrSize); diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp index e076f2b4bf..b6035b5500 100644 --- a/src/network/socket/qnativesocketengine_unix.cpp +++ b/src/network/socket/qnativesocketengine_unix.cpp @@ -144,7 +144,7 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc int protocol = (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) ? AF_INET6 : AF_INET; int type = (socketType == QAbstractSocket::UdpSocket) ? SOCK_DGRAM : SOCK_STREAM; - int socket = qt_safe_socket(protocol, type, 0); + int socket = qt_safe_socket(protocol, type, 0); if (socket <= 0 && socketProtocol == QAbstractSocket::AnyIPProtocol && errno == EAFNOSUPPORT) { protocol = AF_INET; socket = qt_safe_socket(protocol, type, 0); diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp index 751ac9b182..b1c9073eb9 100644 --- a/src/network/socket/qnativesocketengine_win.cpp +++ b/src/network/socket/qnativesocketengine_win.cpp @@ -186,7 +186,7 @@ static inline void qt_socket_getPortAndAddress(SOCKET socketDescriptor, const qt *address = a; } if (port) - WSANtohs(socketDescriptor, sa6->sin6_port, port); + WSANtohs(socketDescriptor, sa6->sin6_port, port); } else if (sa->a.sa_family == AF_INET) { @@ -194,11 +194,11 @@ static inline void qt_socket_getPortAndAddress(SOCKET socketDescriptor, const qt unsigned long addr; WSANtohl(socketDescriptor, sa4->sin_addr.s_addr, &addr); QHostAddress a; - a.setAddress(addr); - if (address) - *address = a; + a.setAddress(addr); + if (address) + *address = a; if (port) - WSANtohs(socketDescriptor, sa4->sin_port, port); + WSANtohs(socketDescriptor, sa4->sin_port, port); } } @@ -276,7 +276,7 @@ QWindowsSockInit::QWindowsSockInit() // IPv6 requires Winsock v2.0 or better. if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0) { - qWarning("QTcpSocketAPI: WinSock v2.0 initialization failed."); + qWarning("QTcpSocketAPI: WinSock v2.0 initialization failed."); } else { version = 0x20; } @@ -940,14 +940,14 @@ int QNativeSocketEnginePrivate::nativeAccept() break; } } else if (acceptedDescriptor != -1 && QAbstractEventDispatcher::instance()) { - // Because of WSAAsyncSelect() WSAAccept returns a non blocking socket - // with the same attributes as the listening socket including the current - // WSAAsyncSelect(). To be able to change the socket to blocking mode the - // WSAAsyncSelect() call must be cancled. - QSocketNotifier n(acceptedDescriptor, QSocketNotifier::Read); - n.setEnabled(true); - n.setEnabled(false); - } + // Because of WSAAsyncSelect() WSAAccept returns a non blocking socket + // with the same attributes as the listening socket including the current + // WSAAsyncSelect(). To be able to change the socket to blocking mode the + // WSAAsyncSelect() call must be cancled. + QSocketNotifier n(acceptedDescriptor, QSocketNotifier::Read); + n.setEnabled(true); + n.setEnabled(false); + } #if defined (QNATIVESOCKETENGINE_DEBUG) qDebug("QNativeSocketEnginePrivate::nativeAccept() == %i", acceptedDescriptor); #endif diff --git a/src/network/socket/qnativesocketengine_winrt.cpp b/src/network/socket/qnativesocketengine_winrt.cpp new file mode 100644 index 0000000000..8550e0b0d1 --- /dev/null +++ b/src/network/socket/qnativesocketengine_winrt.cpp @@ -0,0 +1,327 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 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. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qnativesocketengine_winrt_p.h" + +#include <qnetworkinterface.h> + +QT_BEGIN_NAMESPACE + +QNativeSocketEngine::QNativeSocketEngine(QObject *parent) + : QAbstractSocketEngine(*new QNativeSocketEnginePrivate(), parent) +{ +} + +QNativeSocketEngine::~QNativeSocketEngine() +{ + close(); +} + +bool QNativeSocketEngine::initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(type); + Q_UNUSED(protocol); + return false; +} + +bool QNativeSocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(socketDescriptor); + Q_UNUSED(socketState); + return false; +} + +qintptr QNativeSocketEngine::socketDescriptor() const +{ + Q_UNIMPLEMENTED(); + return -1; +} + +bool QNativeSocketEngine::isValid() const +{ + Q_UNIMPLEMENTED(); + return false; +} + +bool QNativeSocketEngine::connectToHost(const QHostAddress &address, quint16 port) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(address); + Q_UNUSED(port); + return false; +} + +bool QNativeSocketEngine::connectToHostByName(const QString &name, quint16 port) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(name); + Q_UNUSED(port); + return false; +} + +bool QNativeSocketEngine::bind(const QHostAddress &address, quint16 port) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(address); + Q_UNUSED(port); + return false; +} + +bool QNativeSocketEngine::listen() +{ + Q_UNIMPLEMENTED(); + return false; +} + +int QNativeSocketEngine::accept() +{ + Q_UNIMPLEMENTED(); + return -1; +} + +void QNativeSocketEngine::close() +{ +} + +bool QNativeSocketEngine::joinMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &iface) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(groupAddress); + Q_UNUSED(iface); + return false; +} + +bool QNativeSocketEngine::leaveMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &iface) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(groupAddress); + Q_UNUSED(iface); + return false; +} + +QNetworkInterface QNativeSocketEngine::multicastInterface() const +{ + Q_UNIMPLEMENTED(); + return QNetworkInterface(); +} + +bool QNativeSocketEngine::setMulticastInterface(const QNetworkInterface &iface) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(iface); + return false; +} + +qint64 QNativeSocketEngine::bytesAvailable() const +{ + Q_UNIMPLEMENTED(); + return -1; +} + +qint64 QNativeSocketEngine::read(char *data, qint64 maxlen) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(data); + Q_UNUSED(maxlen); + return -1; +} + +qint64 QNativeSocketEngine::write(const char *data, qint64 len) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(data); + Q_UNUSED(len); + return -1; +} + +qint64 QNativeSocketEngine::readDatagram(char *data, qint64 maxlen, QHostAddress *addr, quint16 *port) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(data); + Q_UNUSED(maxlen); + Q_UNUSED(addr); + Q_UNUSED(port); + return -1; +} + +qint64 QNativeSocketEngine::writeDatagram(const char *data, qint64 len, const QHostAddress &addr, quint16 port) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(data); + Q_UNUSED(len); + Q_UNUSED(addr); + Q_UNUSED(port); + return -1; +} + +bool QNativeSocketEngine::hasPendingDatagrams() const +{ + Q_UNIMPLEMENTED(); + return false; +} + +qint64 QNativeSocketEngine::pendingDatagramSize() const +{ + Q_UNIMPLEMENTED(); + return 0; +} + +qint64 QNativeSocketEngine::bytesToWrite() const +{ + Q_UNIMPLEMENTED(); + return 0; +} + +qint64 QNativeSocketEngine::receiveBufferSize() const +{ + Q_UNIMPLEMENTED(); + return 0; +} + +void QNativeSocketEngine::setReceiveBufferSize(qint64 bufferSize) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(bufferSize); +} + +qint64 QNativeSocketEngine::sendBufferSize() const +{ + Q_UNIMPLEMENTED(); + return 0; +} + +void QNativeSocketEngine::setSendBufferSize(qint64 bufferSize) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(bufferSize); +} + +int QNativeSocketEngine::option(QAbstractSocketEngine::SocketOption option) const +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(option); + return -1; +} + +bool QNativeSocketEngine::setOption(QAbstractSocketEngine::SocketOption option, int value) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(option); + Q_UNUSED(value); + return false; +} + +bool QNativeSocketEngine::waitForRead(int msecs, bool *timedOut) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(msecs); + Q_UNUSED(timedOut); + return false; +} + +bool QNativeSocketEngine::waitForWrite(int msecs, bool *timedOut) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(msecs); + Q_UNUSED(timedOut); + return false; +} + +bool QNativeSocketEngine::waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, bool checkRead, bool checkWrite, int msecs, bool *timedOut) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(readyToRead); + Q_UNUSED(readyToWrite); + Q_UNUSED(checkRead); + Q_UNUSED(checkWrite); + Q_UNUSED(msecs); + Q_UNUSED(timedOut); + return false; +} + +bool QNativeSocketEngine::isReadNotificationEnabled() const +{ + Q_UNIMPLEMENTED(); + return false; +} + +void QNativeSocketEngine::setReadNotificationEnabled(bool enable) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(enable); +} + +bool QNativeSocketEngine::isWriteNotificationEnabled() const +{ + Q_UNIMPLEMENTED(); + return false; +} + +void QNativeSocketEngine::setWriteNotificationEnabled(bool enable) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(enable); +} + +bool QNativeSocketEngine::isExceptionNotificationEnabled() const +{ + Q_UNIMPLEMENTED(); + return false; +} + +void QNativeSocketEngine::setExceptionNotificationEnabled(bool enable) +{ + Q_UNIMPLEMENTED(); + Q_UNUSED(enable); +} + +QNativeSocketEnginePrivate::QNativeSocketEnginePrivate() + : QAbstractSocketEnginePrivate() +{ +} + +QNativeSocketEnginePrivate::~QNativeSocketEnginePrivate() +{ +} + +QT_END_NAMESPACE diff --git a/src/network/socket/qnativesocketengine_winrt_p.h b/src/network/socket/qnativesocketengine_winrt_p.h new file mode 100644 index 0000000000..47ba3ecf91 --- /dev/null +++ b/src/network/socket/qnativesocketengine_winrt_p.h @@ -0,0 +1,145 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtNetwork module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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 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. +** +** 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 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QNATIVESOCKETENGINE_WINRT_P_H +#define QNATIVESOCKETENGINE_WINRT_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/qhostaddress.h" +#include "private/qabstractsocketengine_p.h" +#include <wrl.h> +#include <windows.networking.sockets.h> + +QT_BEGIN_NAMESPACE + +class QNativeSocketEnginePrivate; + +class Q_AUTOTEST_EXPORT QNativeSocketEngine : public QAbstractSocketEngine +{ + Q_OBJECT +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); + + qintptr socketDescriptor() const; + + bool isValid() const; + + 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(); + +#ifndef QT_NO_NETWORKINTERFACE + bool joinMulticastGroup(const QHostAddress &groupAddress, + const QNetworkInterface &iface); + bool leaveMulticastGroup(const QHostAddress &groupAddress, + const QNetworkInterface &iface); + QNetworkInterface multicastInterface() const; + bool setMulticastInterface(const QNetworkInterface &iface); +#endif + + qint64 bytesAvailable() const; + + qint64 read(char *data, qint64 maxlen); + qint64 write(const char *data, qint64 len); + + qint64 readDatagram(char *data, qint64 maxlen, QHostAddress *addr = 0, + quint16 *port = 0); + qint64 writeDatagram(const char *data, qint64 len, const QHostAddress &addr, + quint16 port); + bool hasPendingDatagrams() const; + qint64 pendingDatagramSize() const; + + qint64 bytesToWrite() const; + + qint64 receiveBufferSize() const; + void setReceiveBufferSize(qint64 bufferSize); + + qint64 sendBufferSize() const; + void setSendBufferSize(qint64 bufferSize); + + int option(SocketOption option) const; + bool setOption(SocketOption option, int value); + + bool waitForRead(int msecs = 30000, bool *timedOut = 0); + bool waitForWrite(int msecs = 30000, bool *timedOut = 0); + bool waitForReadOrWrite(bool *readyToRead, bool *readyToWrite, + bool checkRead, bool checkWrite, + int msecs = 30000, bool *timedOut = 0); + + bool isReadNotificationEnabled() const; + void setReadNotificationEnabled(bool enable); + bool isWriteNotificationEnabled() const; + void setWriteNotificationEnabled(bool enable); + bool isExceptionNotificationEnabled() const; + void setExceptionNotificationEnabled(bool enable); + +private: + Q_DECLARE_PRIVATE(QNativeSocketEngine) + Q_DISABLE_COPY(QNativeSocketEngine) +}; + +class QNativeSocketEnginePrivate : public QAbstractSocketEnginePrivate +{ + Q_DECLARE_PUBLIC(QNativeSocketEngine) +public: + QNativeSocketEnginePrivate(); + ~QNativeSocketEnginePrivate(); +}; + +QT_END_NAMESPACE + +#endif // QNATIVESOCKETENGINE_WINRT_P_H diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 6818ff6354..b62c4a6bef 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -735,9 +735,10 @@ void QSocks5SocketEnginePrivate::reauthenticate() proxyInfo.setPassword(auth.password()); data->authenticator = new QSocks5PasswordAuthenticator(proxyInfo.user(), proxyInfo.password()); - data->controlSocket->blockSignals(true); - data->controlSocket->abort(); - data->controlSocket->blockSignals(false); + { + const QSignalBlocker blocker(data->controlSocket); + data->controlSocket->abort(); + } data->controlSocket->connectToHost(proxyInfo.hostName(), proxyInfo.port()); } else { // authentication failure diff --git a/src/network/socket/socket.pri b/src/network/socket/socket.pri index c0c6d750d9..7e3a54e303 100644 --- a/src/network/socket/socket.pri +++ b/src/network/socket/socket.pri @@ -24,8 +24,10 @@ SOURCES += socket/qabstractsocketengine.cpp \ socket/qlocalsocket.cpp \ socket/qlocalserver.cpp -SOURCES += socket/qnativesocketengine.cpp -HEADERS += socket/qnativesocketengine_p.h +!winrt { + SOURCES += socket/qnativesocketengine.cpp + HEADERS += socket/qnativesocketengine_p.h +} unix: { SOURCES += socket/qnativesocketengine_unix.cpp \ @@ -36,11 +38,20 @@ unix: { unix:HEADERS += \ socket/qnet_unix_p.h -win32:SOURCES += socket/qnativesocketengine_win.cpp \ +win32:!winrt:SOURCES += socket/qnativesocketengine_win.cpp \ socket/qlocalsocket_win.cpp \ socket/qlocalserver_win.cpp -win32:!wince*: LIBS_PRIVATE += -ladvapi32 +win32:!wince*:!winrt:LIBS_PRIVATE += -ladvapi32 + +winrt { + SOURCES += socket/qnativesocketengine_winrt.cpp \ + socket/qlocalsocket_tcp.cpp \ + socket/qlocalserver_tcp.cpp + HEADERS += socket/qnativesocketengine_winrt_p.h + + DEFINES += QT_LOCALSOCKET_TCP +} wince*: { SOURCES -= socket/qlocalsocket_win.cpp \ |