summaryrefslogtreecommitdiffstats
path: root/src/network/socket
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/socket')
-rw-r--r--src/network/socket/qabstractsocket.cpp96
-rw-r--r--src/network/socket/qabstractsocket.h21
-rw-r--r--src/network/socket/qabstractsocket_p.h4
-rw-r--r--src/network/socket/qabstractsocketengine.cpp4
-rw-r--r--src/network/socket/qabstractsocketengine_p.h13
-rw-r--r--src/network/socket/qhttpsocketengine.cpp30
-rw-r--r--src/network/socket/qhttpsocketengine_p.h9
-rw-r--r--src/network/socket/qlocalserver.cpp2
-rw-r--r--src/network/socket/qlocalserver.h2
-rw-r--r--src/network/socket/qlocalserver_p.h2
-rw-r--r--src/network/socket/qlocalserver_tcp.cpp2
-rw-r--r--src/network/socket/qlocalserver_unix.cpp2
-rw-r--r--src/network/socket/qlocalserver_win.cpp2
-rw-r--r--src/network/socket/qlocalsocket.cpp8
-rw-r--r--src/network/socket/qlocalsocket.h12
-rw-r--r--src/network/socket/qlocalsocket_p.h21
-rw-r--r--src/network/socket/qlocalsocket_tcp.cpp9
-rw-r--r--src/network/socket/qlocalsocket_unix.cpp16
-rw-r--r--src/network/socket/qlocalsocket_win.cpp341
-rw-r--r--src/network/socket/qnativesocketengine.cpp8
-rw-r--r--src/network/socket/qnativesocketengine_p.h8
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp14
-rw-r--r--src/network/socket/qnativesocketengine_win.cpp12
-rw-r--r--src/network/socket/qnet_unix_p.h2
-rw-r--r--src/network/socket/qsocks5socketengine.cpp22
-rw-r--r--src/network/socket/qsocks5socketengine_p.h10
-rw-r--r--src/network/socket/qtcpserver.cpp8
-rw-r--r--src/network/socket/qtcpserver.h8
-rw-r--r--src/network/socket/qtcpsocket.cpp4
-rw-r--r--src/network/socket/qtcpsocket.h2
-rw-r--r--src/network/socket/qtcpsocket_p.h2
-rw-r--r--src/network/socket/qudpsocket.cpp2
-rw-r--r--src/network/socket/qudpsocket.h2
33 files changed, 268 insertions, 432 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index d74a717d93..e1a2449593 100644
--- a/src/network/socket/qabstractsocket.cpp
+++ b/src/network/socket/qabstractsocket.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -163,7 +163,7 @@
issue to be aware of, though: You must make sure that enough data
is available before attempting to read it using operator>>().
- \sa QFtp, QNetworkAccessManager, QTcpServer
+ \sa QNetworkAccessManager, QTcpServer
*/
/*!
@@ -315,6 +315,8 @@
proxy) was not found.
\value ProxyProtocolError The connection negotiation with the proxy server
because the response from the proxy server could not be understood.
+ \value OperationError An operation was attempted while the socket was in a state that
+ did not permit it.
\value UnknownSocketError An unidentified error occurred.
\sa QAbstractSocket::error()
@@ -347,18 +349,40 @@
\enum QAbstractSocket::SocketOption
\since 4.6
- This enum represents the options that can be set on a socket.
- If desired, they can be set after having received the connected() signal from
- the socket or after having received a new socket from a QTcpServer.
+ This enum represents the options that can be set on a socket. If
+ desired, they can be set after having received the connected()
+ signal from the socket or after having received a new socket from
+ a QTcpServer.
- \value LowDelayOption Try to optimize the socket for low latency. For a QTcpSocket
- this would set the TCP_NODELAY option and disable Nagle's algorithm. Set this to 1
- to enable.
- \value KeepAliveOption Set this to 1 to enable the SO_KEEPALIVE socket option
+ \value LowDelayOption Try to optimize the socket for low
+ latency. For a QTcpSocket this would set the TCP_NODELAY option
+ and disable Nagle's algorithm. Set this to 1 to enable.
- \value MulticastTtlOption Set this to an integer value to set IP_MULTICAST_TTL (TTL for multicast datagrams) socket option.
+ \value KeepAliveOption Set this to 1 to enable the SO_KEEPALIVE
+ socket option
- \value MulticastLoopbackOption Set this to 1 to enable the IP_MULTICAST_LOOP (multicast loopback) socket option.
+ \value MulticastTtlOption Set this to an integer value to set
+ IP_MULTICAST_TTL (TTL for multicast datagrams) socket option.
+
+ \value MulticastLoopbackOption Set this to 1 to enable the
+ IP_MULTICAST_LOOP (multicast loopback) socket option.
+
+ \value TypeOfServiceOption This option is not supported on
+ Windows. This maps to to the IP_TOS socket option.
+
+ Possible values for the \e{TypeOfServiceOption} are:
+
+ \table
+ \header \o Value \o Description
+ \row \o 224 \o Network control
+ \row \o 192 \o Internetwork control
+ \row \o 160 \o CRITIC/ECP
+ \row \o 128 \o Flash override
+ \row \o 96 \o Flash
+ \row \o 64 \o Immediate
+ \row \o 32 \o Priority
+ \row \o 0 \o Routine
+ \endtable
\sa QAbstractSocket::setSocketOption(), QAbstractSocket::socketOption()
*/
@@ -939,7 +963,7 @@ void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo)
if (preferredNetworkLayerProtocol == QAbstractSocket::UnknownNetworkLayerProtocol || preferredNetworkLayerProtocol == QAbstractSocket::AnyIPProtocol) {
addresses = hostInfo.addresses();
} else {
- foreach (QHostAddress address, hostInfo.addresses())
+ foreach (const QHostAddress &address, hostInfo.addresses())
if (address.protocol() == preferredNetworkLayerProtocol)
addresses += address;
}
@@ -1455,27 +1479,6 @@ void QAbstractSocket::connectToHost(const QString &hostName, quint16 port,
NetworkLayerProtocol protocol)
{
Q_D(QAbstractSocket);
- d->preferredNetworkLayerProtocol = protocol;
-
- QMetaObject::invokeMethod(this, "connectToHostImplementation",
- Qt::DirectConnection,
- Q_ARG(QString, hostName),
- Q_ARG(quint16, port),
- Q_ARG(OpenMode, openMode));
-}
-
-/*!
- \since 4.1
-
- Contains the implementation of connectToHost().
-
- Attempts to make a connection to \a hostName on the given \a
- port. The socket is opened in the given \a openMode.
-*/
-void QAbstractSocket::connectToHostImplementation(const QString &hostName, quint16 port,
- OpenMode openMode)
-{
- Q_D(QAbstractSocket);
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocket::connectToHost(\"%s\", %i, %i)...", qPrintable(hostName), port,
(int) openMode);
@@ -1484,9 +1487,13 @@ void QAbstractSocket::connectToHostImplementation(const QString &hostName, quint
if (d->state == ConnectedState || d->state == ConnectingState
|| d->state == ClosingState || d->state == HostLookupState) {
qWarning("QAbstractSocket::connectToHost() called when already looking up or connecting/connected to \"%s\"", qPrintable(hostName));
+ d->socketError = QAbstractSocket::OperationError;
+ setErrorString(QAbstractSocket::tr("Trying to connect while connection is in progress"));
+ emit error(d->socketError);
return;
}
+ d->preferredNetworkLayerProtocol = protocol;
d->hostName = hostName;
d->port = port;
d->state = UnconnectedState;
@@ -1705,7 +1712,7 @@ bool QAbstractSocket::canReadLine() const
\sa setSocketDescriptor()
*/
-int QAbstractSocket::socketDescriptor() const
+qintptr QAbstractSocket::socketDescriptor() const
{
Q_D(const QAbstractSocket);
return d->cachedSocketDescriptor;
@@ -1723,7 +1730,7 @@ int QAbstractSocket::socketDescriptor() const
\sa socketDescriptor()
*/
-bool QAbstractSocket::setSocketDescriptor(int socketDescriptor, SocketState socketState,
+bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState socketState,
OpenMode openMode)
{
Q_D(QAbstractSocket);
@@ -1805,6 +1812,10 @@ void QAbstractSocket::setSocketOption(QAbstractSocket::SocketOption option, cons
case MulticastLoopbackOption:
d_func()->socketEngine->setOption(QAbstractSocketEngine::MulticastLoopbackOption, value.toInt());
break;
+
+ case TypeOfServiceOption:
+ d_func()->socketEngine->setOption(QAbstractSocketEngine::TypeOfServiceOption, value.toInt());
+ break;
}
}
@@ -1841,6 +1852,10 @@ QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option)
case MulticastLoopbackOption:
ret = d_func()->socketEngine->option(QAbstractSocketEngine::MulticastLoopbackOption);
break;
+
+ case TypeOfServiceOption:
+ ret = d_func()->socketEngine->option(QAbstractSocketEngine::TypeOfServiceOption);
+ break;
}
if (ret == -1)
return QVariant();
@@ -2595,17 +2610,6 @@ void QAbstractSocket::close()
*/
void QAbstractSocket::disconnectFromHost()
{
- QMetaObject::invokeMethod(this, "disconnectFromHostImplementation",
- Qt::DirectConnection);
-}
-
-/*!
- \since 4.1
-
- Contains the implementation of disconnectFromHost().
-*/
-void QAbstractSocket::disconnectFromHostImplementation()
-{
Q_D(QAbstractSocket);
#if defined(QABSTRACTSOCKET_DEBUG)
qDebug("QAbstractSocket::disconnectFromHost()");
diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h
index ee910e3b33..e821f3ddb2 100644
--- a/src/network/socket/qabstractsocket.h
+++ b/src/network/socket/qabstractsocket.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -97,6 +97,7 @@ public:
ProxyConnectionTimeoutError,
ProxyNotFoundError,
ProxyProtocolError,
+ OperationError,
UnknownSocketError = -1
};
@@ -113,7 +114,8 @@ public:
LowDelayOption, // TCP_NODELAY
KeepAliveOption, // SO_KEEPALIVE
MulticastTtlOption, // IP_MULTICAST_TTL
- MulticastLoopbackOption // IP_MULTICAST_LOOPBACK
+ MulticastLoopbackOption, // IP_MULTICAST_LOOPBACK
+ TypeOfServiceOption //IP_TOS
};
enum BindFlag {
DefaultForPlatform = 0x0,
@@ -129,10 +131,9 @@ public:
bool bind(const QHostAddress &address, quint16 port = 0, BindMode mode = DefaultForPlatform);
bool bind(quint16 port = 0, BindMode mode = DefaultForPlatform);
- // ### Qt 5: Make connectToHost() and disconnectFromHost() virtual.
- void connectToHost(const QString &hostName, quint16 port, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
- void connectToHost(const QHostAddress &address, quint16 port, OpenMode mode = ReadWrite);
- void disconnectFromHost();
+ 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;
@@ -154,8 +155,8 @@ public:
void abort();
// ### Qt 5: Make socketDescriptor() and setSocketDescriptor() virtual.
- int socketDescriptor() const;
- bool setSocketDescriptor(int socketDescriptor, SocketState state = ConnectedState,
+ qintptr socketDescriptor() const;
+ bool setSocketDescriptor(qintptr socketDescriptor, SocketState state = ConnectedState,
OpenMode openMode = ReadWrite);
// ### Qt 5: Make virtual?
@@ -194,10 +195,6 @@ Q_SIGNALS:
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator);
#endif
-protected Q_SLOTS:
- void connectToHostImplementation(const QString &hostName, quint16 port, OpenMode mode = ReadWrite);
- void disconnectFromHostImplementation();
-
protected:
qint64 readData(char *data, qint64 maxlen);
qint64 readLineData(char *data, qint64 maxlen);
diff --git a/src/network/socket/qabstractsocket_p.h b/src/network/socket/qabstractsocket_p.h
index 978fb1433a..49e7c82e21 100644
--- a/src/network/socket/qabstractsocket_p.h
+++ b/src/network/socket/qabstractsocket_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -118,7 +118,7 @@ public:
QString peerName;
QAbstractSocketEngine *socketEngine;
- int cachedSocketDescriptor;
+ qintptr cachedSocketDescriptor;
#ifndef QT_NO_NETWORKPROXY
QNetworkProxy proxy;
diff --git a/src/network/socket/qabstractsocketengine.cpp b/src/network/socket/qabstractsocketengine.cpp
index 7fc0ea3993..8c1ee88ce1 100644
--- a/src/network/socket/qabstractsocketengine.cpp
+++ b/src/network/socket/qabstractsocketengine.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -118,7 +118,7 @@ QAbstractSocketEngine *QAbstractSocketEngine::createSocketEngine(QAbstractSocket
return new QNativeSocketEngine(parent);
}
-QAbstractSocketEngine *QAbstractSocketEngine::createSocketEngine(int socketDescripter, QObject *parent)
+QAbstractSocketEngine *QAbstractSocketEngine::createSocketEngine(qintptr socketDescripter, QObject *parent)
{
QMutexLocker locker(&socketHandlers()->mutex);
for (int i = 0; i < socketHandlers()->size(); i++) {
diff --git a/src/network/socket/qabstractsocketengine_p.h b/src/network/socket/qabstractsocketengine_p.h
index a8be98a0cf..e365eb8b5e 100644
--- a/src/network/socket/qabstractsocketengine_p.h
+++ b/src/network/socket/qabstractsocketengine_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -84,7 +84,7 @@ class Q_AUTOTEST_EXPORT QAbstractSocketEngine : public QObject
public:
static QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType, const QNetworkProxy &, QObject *parent);
- static QAbstractSocketEngine *createSocketEngine(int socketDescripter, QObject *parent);
+ static QAbstractSocketEngine *createSocketEngine(qintptr socketDescriptor, QObject *parent);
QAbstractSocketEngine(QObject *parent = 0);
@@ -99,14 +99,15 @@ public:
LowDelayOption,
KeepAliveOption,
MulticastTtlOption,
- MulticastLoopbackOption
+ MulticastLoopbackOption,
+ TypeOfServiceOption
};
virtual bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol) = 0;
- virtual bool initialize(int socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState) = 0;
+ virtual bool initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState) = 0;
- virtual int socketDescriptor() const = 0;
+ virtual qintptr socketDescriptor() const = 0;
virtual bool isValid() const = 0;
@@ -224,7 +225,7 @@ protected:
virtual ~QSocketEngineHandler();
virtual QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType,
const QNetworkProxy &, QObject *parent) = 0;
- virtual QAbstractSocketEngine *createSocketEngine(int socketDescripter, QObject *parent) = 0;
+ virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescriptor, QObject *parent) = 0;
private:
friend class QAbstractSocketEngine;
diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp
index fd0119b8fd..e882f77dcd 100644
--- a/src/network/socket/qhttpsocketengine.cpp
+++ b/src/network/socket/qhttpsocketengine.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -43,7 +43,7 @@
#include "qtcpsocket.h"
#include "qhostaddress.h"
#include "qurl.h"
-#include "qhttp.h"
+#include "private/qhttpheader_p.h"
#include "qelapsedtimer.h"
#include "qnetworkinterface.h"
@@ -103,7 +103,7 @@ bool QHttpSocketEngine::initialize(QAbstractSocket::SocketType type, QAbstractSo
return true;
}
-bool QHttpSocketEngine::initialize(int, QAbstractSocket::SocketState)
+bool QHttpSocketEngine::initialize(qintptr, QAbstractSocket::SocketState)
{
return false;
}
@@ -120,7 +120,7 @@ void QHttpSocketEngine::setProxy(const QNetworkProxy &proxy)
d->authenticator.setPassword(password);
}
-int QHttpSocketEngine::socketDescriptor() const
+qintptr QHttpSocketEngine::socketDescriptor() const
{
Q_D(const QHttpSocketEngine);
return d->socket ? d->socket->socketDescriptor() : 0;
@@ -136,6 +136,8 @@ bool QHttpSocketEngine::connectInternal()
{
Q_D(QHttpSocketEngine);
+ d->credentialsSent = false;
+
// If the handshake is done, enter ConnectedState state and return true.
if (d->state == Connected) {
qWarning("QHttpSocketEngine::connectToHost: called when already connected");
@@ -512,6 +514,7 @@ void QHttpSocketEngine::slotSocketConnected()
QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(d->authenticator);
//qDebug() << "slotSocketConnected: priv=" << priv << (priv ? (int)priv->method : -1);
if (priv && priv->method != QAuthenticatorPrivate::None) {
+ d->credentialsSent = true;
data += "Proxy-Authorization: " + priv->calculateResponse(method, path);
data += "\r\n";
}
@@ -589,15 +592,26 @@ void QHttpSocketEngine::slotSocketReadNotification()
d->readBuffer.clear(); // we parsed the proxy protocol response. from now on direct socket reading will be done
int statusCode = responseHeader.statusCode();
+ QAuthenticatorPrivate *priv = 0;
if (statusCode == 200) {
d->state = Connected;
setLocalAddress(d->socket->localAddress());
setLocalPort(d->socket->localPort());
setState(QAbstractSocket::ConnectedState);
+ d->authenticator.detach();
+ priv = QAuthenticatorPrivate::getPrivate(d->authenticator);
+ priv->hasFailed = false;
} else if (statusCode == 407) {
- if (d->authenticator.isNull())
+ if (d->credentialsSent) {
+ //407 response again means the provided username/password were invalid.
+ d->authenticator = QAuthenticator(); //this is needed otherwise parseHttpResponse won't set the state, and then signal isn't emitted.
+ d->authenticator.detach();
+ priv = QAuthenticatorPrivate::getPrivate(d->authenticator);
+ priv->hasFailed = true;
+ }
+ else if (d->authenticator.isNull())
d->authenticator.detach();
- QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(d->authenticator);
+ priv = QAuthenticatorPrivate::getPrivate(d->authenticator);
priv->parseHttpResponse(responseHeader, true);
@@ -637,7 +651,6 @@ void QHttpSocketEngine::slotSocketReadNotification()
if (priv->phase == QAuthenticatorPrivate::Done)
emit proxyAuthenticationRequired(d->proxy, &d->authenticator);
-
// priv->phase will get reset to QAuthenticatorPrivate::Start if the authenticator got modified in the signal above.
if (priv->phase == QAuthenticatorPrivate::Done) {
setError(QAbstractSocket::ProxyAuthenticationRequiredError, tr("Authentication required"));
@@ -794,6 +807,7 @@ QHttpSocketEnginePrivate::QHttpSocketEnginePrivate()
, readNotificationPending(false)
, writeNotificationPending(false)
, connectionNotificationPending(false)
+ , credentialsSent(false)
, pendingResponseData(0)
{
socket = 0;
@@ -824,7 +838,7 @@ QAbstractSocketEngine *QHttpSocketEngineHandler::createSocketEngine(QAbstractSoc
return engine;
}
-QAbstractSocketEngine *QHttpSocketEngineHandler::createSocketEngine(int, QObject *)
+QAbstractSocketEngine *QHttpSocketEngineHandler::createSocketEngine(qintptr, QObject *)
{
return 0;
}
diff --git a/src/network/socket/qhttpsocketengine_p.h b/src/network/socket/qhttpsocketengine_p.h
index d7cc7c1604..1a93956bd2 100644
--- a/src/network/socket/qhttpsocketengine_p.h
+++ b/src/network/socket/qhttpsocketengine_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -80,11 +80,11 @@ public:
~QHttpSocketEngine();
bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol);
- bool initialize(int socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState);
+ bool initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState);
void setProxy(const QNetworkProxy &networkProxy);
- int socketDescriptor() const;
+ qintptr socketDescriptor() const;
bool isValid() const;
@@ -182,6 +182,7 @@ public:
bool readNotificationPending;
bool writeNotificationPending;
bool connectionNotificationPending;
+ bool credentialsSent;
uint pendingResponseData;
};
@@ -190,7 +191,7 @@ class Q_AUTOTEST_EXPORT QHttpSocketEngineHandler : public QSocketEngineHandler
public:
virtual QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType,
const QNetworkProxy &, QObject *parent);
- virtual QAbstractSocketEngine *createSocketEngine(int socketDescripter, QObject *parent);
+ virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescripter, QObject *parent);
};
#endif
diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp
index ffd87aa946..fc5fe3443e 100644
--- a/src/network/socket/qlocalserver.cpp
+++ b/src/network/socket/qlocalserver.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/network/socket/qlocalserver.h b/src/network/socket/qlocalserver.h
index 4468bf90e3..6887c16056 100644
--- a/src/network/socket/qlocalserver.h
+++ b/src/network/socket/qlocalserver.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/network/socket/qlocalserver_p.h b/src/network/socket/qlocalserver_p.h
index ed699fc1d5..d762818692 100644
--- a/src/network/socket/qlocalserver_p.h
+++ b/src/network/socket/qlocalserver_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/network/socket/qlocalserver_tcp.cpp b/src/network/socket/qlocalserver_tcp.cpp
index 47c4204802..cb4ee53f6a 100644
--- a/src/network/socket/qlocalserver_tcp.cpp
+++ b/src/network/socket/qlocalserver_tcp.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp
index e0115de8d2..5859ab0080 100644
--- a/src/network/socket/qlocalserver_unix.cpp
+++ b/src/network/socket/qlocalserver_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/network/socket/qlocalserver_win.cpp b/src/network/socket/qlocalserver_win.cpp
index 8e6bbc6deb..bdbe4d74f1 100644
--- a/src/network/socket/qlocalserver_win.cpp
+++ b/src/network/socket/qlocalserver_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp
index 219d2aa8ad..e311f6a060 100644
--- a/src/network/socket/qlocalsocket.cpp
+++ b/src/network/socket/qlocalsocket.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -94,7 +94,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn bool QLocalSocket::setSocketDescriptor(quintptr socketDescriptor,
+ \fn bool QLocalSocket::setSocketDescriptor(qintptr socketDescriptor,
LocalSocketState socketState, OpenMode openMode)
Initializes QLocalSocket with the native socket descriptor
@@ -110,7 +110,7 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn quintptr QLocalSocket::socketDescriptor() const
+ \fn qintptr QLocalSocket::socketDescriptor() const
Returns the native socket descriptor of the QLocalSocket object if
this is available; otherwise returns -1.
@@ -419,6 +419,8 @@ bool QLocalSocket::isSequential() const
\value ConnectionError An error occurred with the connection.
\value UnsupportedSocketOperationError The requested socket operation
is not supported by the local operating system.
+ \value OperationError An operation was attempted while the socket was in a state that
+ did not permit it.
\value UnknownSocketError An unidentified error occurred.
*/
diff --git a/src/network/socket/qlocalsocket.h b/src/network/socket/qlocalsocket.h
index 698c06377b..bb39b0f4c8 100644
--- a/src/network/socket/qlocalsocket.h
+++ b/src/network/socket/qlocalsocket.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -72,7 +72,8 @@ public:
DatagramTooLargeError = QAbstractSocket::DatagramTooLargeError,
ConnectionError = QAbstractSocket::NetworkError,
UnsupportedSocketOperationError = QAbstractSocket::UnsupportedSocketOperationError,
- UnknownSocketError = QAbstractSocket::UnknownSocketError
+ UnknownSocketError = QAbstractSocket::UnknownSocketError,
+ OperationError = QAbstractSocket::OperationError
};
enum LocalSocketState
@@ -104,10 +105,10 @@ public:
qint64 readBufferSize() const;
void setReadBufferSize(qint64 size);
- bool setSocketDescriptor(quintptr socketDescriptor,
+ bool setSocketDescriptor(qintptr socketDescriptor,
LocalSocketState socketState = ConnectedState,
OpenMode openMode = ReadWrite);
- quintptr socketDescriptor() const;
+ qintptr socketDescriptor() const;
LocalSocketState state() const;
bool waitForBytesWritten(int msecs = 30000);
@@ -131,10 +132,9 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QAbstractSocket::SocketState))
Q_PRIVATE_SLOT(d_func(), void _q_error(QAbstractSocket::SocketError))
#elif defined(Q_OS_WIN)
- Q_PRIVATE_SLOT(d_func(), void _q_notified())
Q_PRIVATE_SLOT(d_func(), void _q_canWrite())
Q_PRIVATE_SLOT(d_func(), void _q_pipeClosed())
- Q_PRIVATE_SLOT(d_func(), void _q_emitReadyRead())
+ Q_PRIVATE_SLOT(d_func(), void _q_winError(ulong, const QString &))
#else
Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QAbstractSocket::SocketState))
Q_PRIVATE_SLOT(d_func(), void _q_error(QAbstractSocket::SocketError))
diff --git a/src/network/socket/qlocalsocket_p.h b/src/network/socket/qlocalsocket_p.h
index a0749fd35f..3541d950e8 100644
--- a/src/network/socket/qlocalsocket_p.h
+++ b/src/network/socket/qlocalsocket_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -63,8 +63,8 @@
#if defined(QT_LOCALSOCKET_TCP)
# include "qtcpsocket.h"
#elif defined(Q_OS_WIN)
+# include "private/qwindowspipereader_p.h"
# include "private/qwindowspipewriter_p.h"
-# include "private/qringbuffer_p.h"
# include <qwineventnotifier.h>
#else
# include "private/qabstractsocketengine_p.h"
@@ -131,26 +131,13 @@ public:
~QLocalSocketPrivate();
void destroyPipeHandles();
void setErrorString(const QString &function);
- void _q_notified();
void _q_canWrite();
void _q_pipeClosed();
- void _q_emitReadyRead();
- DWORD checkPipeState();
- void startAsyncRead();
- bool completeAsyncRead();
- void checkReadyRead();
+ void _q_winError(ulong windowsError, const QString &function);
HANDLE handle;
- OVERLAPPED overlapped;
QWindowsPipeWriter *pipeWriter;
- qint64 readBufferMaxSize;
- QRingBuffer readBuffer;
- int actualReadBufferSize;
- QWinEventNotifier *dataReadNotifier;
+ QWindowsPipeReader *pipeReader;
QLocalSocket::LocalSocketError error;
- bool readSequenceStarted;
- bool pendingReadyRead;
- bool pipeClosed;
- static const qint64 initialReadBufferSize = 4096;
#else
QLocalUnixSocket unixSocket;
QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const;
diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp
index 38d2b627b1..3b83d0ee01 100644
--- a/src/network/socket/qlocalsocket_tcp.cpp
+++ b/src/network/socket/qlocalsocket_tcp.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -155,6 +155,9 @@ QString QLocalSocketPrivate::generateErrorString(QLocalSocket::LocalSocketError
case QLocalSocket::UnsupportedSocketOperationError:
errorString = QLocalSocket::tr("%1: The socket operation is not supported").arg(function);
break;
+ case QLocalSocket::OperationError:
+ errorString = QLocalSocket::tr("%1: Operation not permitted when socket is in this state").arg(function);
+ break;
case QLocalSocket::UnknownSocketError:
default:
errorString = QLocalSocket::tr("%1: Unknown error").arg(function);
@@ -247,7 +250,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode)
QIODevice::open(openMode);
}
-bool QLocalSocket::setSocketDescriptor(quintptr socketDescriptor,
+bool QLocalSocket::setSocketDescriptor(qintptr socketDescriptor,
LocalSocketState socketState, OpenMode openMode)
{
Q_D(QLocalSocket);
@@ -287,7 +290,7 @@ bool QLocalSocket::setSocketDescriptor(quintptr socketDescriptor,
newSocketState, openMode);
}
-quintptr QLocalSocket::socketDescriptor() const
+qintptr QLocalSocket::socketDescriptor() const
{
Q_D(const QLocalSocket);
return d->tcpSocket->socketDescriptor();
diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp
index 1bdf604eb1..5bd929d477 100644
--- a/src/network/socket/qlocalsocket_unix.cpp
+++ b/src/network/socket/qlocalsocket_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -162,6 +162,9 @@ QString QLocalSocketPrivate::generateErrorString(QLocalSocket::LocalSocketError
case QLocalSocket::UnsupportedSocketOperationError:
errorString = QLocalSocket::tr("%1: The socket operation is not supported").arg(function);
break;
+ case QLocalSocket::OperationError:
+ errorString = QLocalSocket::tr("%1: Operation not permitted when socket is in this state").arg(function);
+ break;
case QLocalSocket::UnknownSocketError:
default:
errorString = QLocalSocket::tr("%1: Unknown error %2").arg(function).arg(errno);
@@ -221,9 +224,12 @@ void QLocalSocketPrivate::errorOccurred(QLocalSocket::LocalSocketError error, co
void QLocalSocket::connectToServer(const QString &name, OpenMode openMode)
{
Q_D(QLocalSocket);
- if (state() == ConnectedState
- || state() == ConnectingState)
+ if (state() == ConnectedState || state() == ConnectingState) {
+ QString errorString = d->generateErrorString(QLocalSocket::OperationError, QLatin1String("QLocalSocket::connectToserver"));
+ setErrorString(errorString);
+ emit error(QLocalSocket::OperationError);
return;
+ }
d->errorString.clear();
d->unixSocket.setSocketState(QAbstractSocket::ConnectingState);
@@ -343,7 +349,7 @@ void QLocalSocketPrivate::_q_connectToSocket()
connectingOpenMode = 0;
}
-bool QLocalSocket::setSocketDescriptor(quintptr socketDescriptor,
+bool QLocalSocket::setSocketDescriptor(qintptr socketDescriptor,
LocalSocketState socketState, OpenMode openMode)
{
Q_D(QLocalSocket);
@@ -386,7 +392,7 @@ void QLocalSocketPrivate::cancelDelayedConnect()
}
}
-quintptr QLocalSocket::socketDescriptor() const
+qintptr QLocalSocket::socketDescriptor() const
{
Q_D(const QLocalSocket);
return d->unixSocket.socketDescriptor();
diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp
index f595ba72ae..99942a6138 100644
--- a/src/network/socket/qlocalsocket_win.cpp
+++ b/src/network/socket/qlocalsocket_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -50,16 +50,21 @@ QT_BEGIN_NAMESPACE
void QLocalSocketPrivate::init()
{
Q_Q(QLocalSocket);
- memset(&overlapped, 0, sizeof(overlapped));
- overlapped.hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- dataReadNotifier = new QWinEventNotifier(overlapped.hEvent, q);
- q->connect(dataReadNotifier, SIGNAL(activated(HANDLE)), q, SLOT(_q_notified()));
+ pipeReader = new QWindowsPipeReader(q);
+ q->connect(pipeReader, SIGNAL(readyRead()), SIGNAL(readyRead()));
+ q->connect(pipeReader, SIGNAL(pipeClosed()), SLOT(_q_pipeClosed()), Qt::QueuedConnection);
+ q->connect(pipeReader, SIGNAL(winError(ulong, const QString &)), SLOT(_q_winError(ulong, const QString &)));
}
void QLocalSocketPrivate::setErrorString(const QString &function)
{
+ DWORD windowsError = GetLastError();
+ _q_winError(windowsError, function);
+}
+
+void QLocalSocketPrivate::_q_winError(ulong windowsError, const QString &function)
+{
Q_Q(QLocalSocket);
- BOOL windowsError = GetLastError();
QLocalSocket::LocalSocketState currentState = state;
// If the connectToServer fails due to WaitNamedPipe() time-out, assume ConnectionError
@@ -95,7 +100,7 @@ void QLocalSocketPrivate::setErrorString(const QString &function)
if (currentState != state) {
q->emit stateChanged(state);
- if (state == QLocalSocket::UnconnectedState)
+ if (state == QLocalSocket::UnconnectedState && currentState != QLocalSocket::ConnectingState)
q->emit disconnected();
}
emit q->error(error);
@@ -103,13 +108,9 @@ void QLocalSocketPrivate::setErrorString(const QString &function)
QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(),
handle(INVALID_HANDLE_VALUE),
+ pipeReader(0),
pipeWriter(0),
- readBufferMaxSize(0),
- actualReadBufferSize(0),
error(QLocalSocket::UnknownSocketError),
- readSequenceStarted(false),
- pendingReadyRead(false),
- pipeClosed(false),
state(QLocalSocket::UnconnectedState)
{
}
@@ -117,7 +118,6 @@ QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(),
QLocalSocketPrivate::~QLocalSocketPrivate()
{
destroyPipeHandles();
- CloseHandle(overlapped.hEvent);
}
void QLocalSocketPrivate::destroyPipeHandles()
@@ -131,8 +131,11 @@ void QLocalSocketPrivate::destroyPipeHandles()
void QLocalSocket::connectToServer(const QString &name, OpenMode openMode)
{
Q_D(QLocalSocket);
- if (state() == ConnectedState || state() == ConnectingState)
+ if (state() == ConnectedState || state() == ConnectingState) {
+ setErrorString(tr("Trying to connect while connection is in progress"));
+ emit error(QLocalSocket::OperationError);
return;
+ }
d->error = QLocalSocket::UnknownSocketError;
d->errorString = QString();
@@ -186,7 +189,7 @@ void QLocalSocket::connectToServer(const QString &name, OpenMode openMode)
// we have a valid handle
d->serverName = name;
- if (setSocketDescriptor((quintptr)localSocket, ConnectedState, openMode)) {
+ if (setSocketDescriptor((qintptr)localSocket, ConnectedState, openMode)) {
d->handle = localSocket;
emit connected();
}
@@ -197,146 +200,7 @@ qint64 QLocalSocket::readData(char *data, qint64 maxSize)
{
Q_D(QLocalSocket);
- if (d->pipeClosed && d->actualReadBufferSize == 0)
- return -1; // signal EOF
-
- qint64 readSoFar;
- // If startAsyncRead() read data, copy it to its destination.
- if (maxSize == 1 && d->actualReadBufferSize > 0) {
- *data = d->readBuffer.getChar();
- d->actualReadBufferSize--;
- readSoFar = 1;
- } else {
- qint64 bytesToRead = qMin(qint64(d->actualReadBufferSize), maxSize);
- readSoFar = 0;
- while (readSoFar < bytesToRead) {
- const char *ptr = d->readBuffer.readPointer();
- int bytesToReadFromThisBlock = qMin(bytesToRead - readSoFar,
- qint64(d->readBuffer.nextDataBlockSize()));
- memcpy(data + readSoFar, ptr, bytesToReadFromThisBlock);
- readSoFar += bytesToReadFromThisBlock;
- d->readBuffer.free(bytesToReadFromThisBlock);
- d->actualReadBufferSize -= bytesToReadFromThisBlock;
- }
- }
-
- if (d->pipeClosed) {
- if (d->actualReadBufferSize == 0)
- QTimer::singleShot(0, this, SLOT(_q_pipeClosed()));
- } else {
- if (!d->readSequenceStarted)
- d->startAsyncRead();
- d->checkReadyRead();
- }
-
- return readSoFar;
-}
-
-/*!
- \internal
- Schedules or cancels a readyRead() emission depending on actual data availability
- */
-void QLocalSocketPrivate::checkReadyRead()
-{
- if (actualReadBufferSize > 0) {
- if (!pendingReadyRead) {
- Q_Q(QLocalSocket);
- QTimer::singleShot(0, q, SLOT(_q_emitReadyRead()));
- pendingReadyRead = true;
- }
- } else {
- pendingReadyRead = false;
- }
-}
-
-/*!
- \internal
- Reads data from the socket into the readbuffer
- */
-void QLocalSocketPrivate::startAsyncRead()
-{
- do {
- DWORD bytesToRead = checkPipeState();
- if (pipeClosed)
- return;
-
- if (bytesToRead == 0) {
- // There are no bytes in the pipe but we need to
- // start the overlapped read with some buffer size.
- bytesToRead = initialReadBufferSize;
- }
-
- if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - readBuffer.size())) {
- bytesToRead = readBufferMaxSize - readBuffer.size();
- if (bytesToRead == 0) {
- // Buffer is full. User must read data from the buffer
- // before we can read more from the pipe.
- return;
- }
- }
-
- char *ptr = readBuffer.reserve(bytesToRead);
-
- readSequenceStarted = true;
- if (ReadFile(handle, ptr, bytesToRead, NULL, &overlapped)) {
- completeAsyncRead();
- } else {
- switch (GetLastError()) {
- case ERROR_IO_PENDING:
- // This is not an error. We're getting notified, when data arrives.
- return;
- case ERROR_MORE_DATA:
- // This is not an error. The synchronous read succeeded.
- // We're connected to a message mode pipe and the message
- // didn't fit into the pipe's system buffer.
- completeAsyncRead();
- break;
- case ERROR_PIPE_NOT_CONNECTED:
- {
- // It may happen, that the other side closes the connection directly
- // after writing data. Then we must set the appropriate socket state.
- pipeClosed = true;
- Q_Q(QLocalSocket);
- emit q->readChannelFinished();
- return;
- }
- default:
- setErrorString(QLatin1String("QLocalSocketPrivate::startAsyncRead"));
- return;
- }
- }
- } while (!readSequenceStarted);
-}
-
-/*!
- \internal
- Sets the correct size of the read buffer after a read operation.
- Returns false, if an error occurred or the connection dropped.
- */
-bool QLocalSocketPrivate::completeAsyncRead()
-{
- ResetEvent(overlapped.hEvent);
- readSequenceStarted = false;
-
- DWORD bytesRead;
- if (!GetOverlappedResult(handle, &overlapped, &bytesRead, TRUE)) {
- switch (GetLastError()) {
- case ERROR_MORE_DATA:
- // This is not an error. We're connected to a message mode
- // pipe and the message didn't fit into the pipe's system
- // buffer. We will read the remaining data in the next call.
- break;
- case ERROR_PIPE_NOT_CONNECTED:
- return false;
- default:
- setErrorString(QLatin1String("QLocalSocketPrivate::completeAsyncRead"));
- return false;
- }
- }
-
- actualReadBufferSize += bytesRead;
- readBuffer.truncate(actualReadBufferSize);
- return true;
+ return d->pipeReader->read(data, maxSize);
}
qint64 QLocalSocket::writeData(const char *data, qint64 maxSize)
@@ -361,39 +225,38 @@ void QLocalSocket::abort()
close();
}
-/*!
- \internal
- Returns the number of available bytes in the pipe.
- Sets QLocalSocketPrivate::pipeClosed to true if the connection is broken.
- */
-DWORD QLocalSocketPrivate::checkPipeState()
+void QLocalSocketPrivate::_q_pipeClosed()
{
Q_Q(QLocalSocket);
- DWORD bytes;
- if (PeekNamedPipe(handle, NULL, 0, NULL, &bytes, NULL)) {
- return bytes;
- } else {
- if (!pipeClosed) {
- pipeClosed = true;
- emit q->readChannelFinished();
- if (actualReadBufferSize == 0)
- QTimer::singleShot(0, q, SLOT(_q_pipeClosed()));
- }
+ if (state == QLocalSocket::UnconnectedState)
+ return;
+
+ emit q->readChannelFinished();
+ if (state != QLocalSocket::ClosingState) {
+ state = QLocalSocket::ClosingState;
+ emit q->stateChanged(state);
+ if (state != QLocalSocket::ClosingState)
+ return;
}
- return 0;
-}
+ state = QLocalSocket::UnconnectedState;
+ emit q->stateChanged(state);
+ emit q->disconnected();
-void QLocalSocketPrivate::_q_pipeClosed()
-{
- Q_Q(QLocalSocket);
- q->close();
+ pipeReader->stop();
+ destroyPipeHandles();
+ handle = INVALID_HANDLE_VALUE;
+
+ if (pipeWriter) {
+ delete pipeWriter;
+ pipeWriter = 0;
+ }
}
qint64 QLocalSocket::bytesAvailable() const
{
Q_D(const QLocalSocket);
qint64 available = QIODevice::bytesAvailable();
- available += (qint64) d->actualReadBufferSize;
+ available += d->pipeReader->bytesAvailable();
return available;
}
@@ -406,42 +269,26 @@ qint64 QLocalSocket::bytesToWrite() const
bool QLocalSocket::canReadLine() const
{
Q_D(const QLocalSocket);
- if (state() != ConnectedState)
- return false;
- return (QIODevice::canReadLine()
- || d->readBuffer.indexOf('\n', d->actualReadBufferSize) != -1);
+ return QIODevice::canReadLine() || d->pipeReader->canReadLine();
}
void QLocalSocket::close()
{
Q_D(QLocalSocket);
- if (state() == UnconnectedState)
+ if (openMode() == NotOpen)
return;
QIODevice::close();
- d->state = ClosingState;
- emit stateChanged(d->state);
- if (!d->pipeClosed)
- emit readChannelFinished();
d->serverName = QString();
d->fullServerName = QString();
- if (state() != UnconnectedState && bytesToWrite() > 0) {
- disconnectFromServer();
- return;
- }
- d->readSequenceStarted = false;
- d->pendingReadyRead = false;
- d->pipeClosed = false;
- d->destroyPipeHandles();
- d->handle = INVALID_HANDLE_VALUE;
- ResetEvent(d->overlapped.hEvent);
- d->state = UnconnectedState;
- emit stateChanged(d->state);
- emit disconnected();
- if (d->pipeWriter) {
- delete d->pipeWriter;
- d->pipeWriter = 0;
+ if (state() != UnconnectedState) {
+ if (bytesToWrite() > 0) {
+ disconnectFromServer();
+ return;
+ }
+
+ d->_q_pipeClosed();
}
}
@@ -480,20 +327,18 @@ QLocalSocket::LocalSocketError QLocalSocket::error() const
return d->error;
}
-bool QLocalSocket::setSocketDescriptor(quintptr socketDescriptor,
+bool QLocalSocket::setSocketDescriptor(qintptr socketDescriptor,
LocalSocketState socketState, OpenMode openMode)
{
Q_D(QLocalSocket);
- d->readBuffer.clear();
- d->actualReadBufferSize = 0;
- QIODevice::open(openMode);
- d->handle = (int*)socketDescriptor;
+ d->pipeReader->stop();
+ d->handle = reinterpret_cast<HANDLE>(socketDescriptor);
d->state = socketState;
+ d->pipeReader->setHandle(d->handle);
+ QIODevice::open(openMode);
emit stateChanged(d->state);
- if (d->state == ConnectedState && openMode.testFlag(QIODevice::ReadOnly)) {
- d->startAsyncRead();
- d->checkReadyRead();
- }
+ if (d->state == ConnectedState && openMode.testFlag(QIODevice::ReadOnly))
+ d->pipeReader->startAsyncRead();
return true;
}
@@ -504,46 +349,22 @@ void QLocalSocketPrivate::_q_canWrite()
q->close();
}
-void QLocalSocketPrivate::_q_notified()
-{
- Q_Q(QLocalSocket);
- if (!completeAsyncRead()) {
- pipeClosed = true;
- emit q->readChannelFinished();
- if (actualReadBufferSize == 0)
- QTimer::singleShot(0, q, SLOT(_q_pipeClosed()));
- return;
- }
- startAsyncRead();
- pendingReadyRead = false;
- emit q->readyRead();
-}
-
-void QLocalSocketPrivate::_q_emitReadyRead()
-{
- if (pendingReadyRead) {
- Q_Q(QLocalSocket);
- pendingReadyRead = false;
- emit q->readyRead();
- }
-}
-
-quintptr QLocalSocket::socketDescriptor() const
+qintptr QLocalSocket::socketDescriptor() const
{
Q_D(const QLocalSocket);
- return (quintptr)d->handle;
+ return (qintptr)d->handle;
}
qint64 QLocalSocket::readBufferSize() const
{
Q_D(const QLocalSocket);
- return d->readBufferMaxSize;
+ return d->pipeReader->maxReadBufferSize();
}
void QLocalSocket::setReadBufferSize(qint64 size)
{
Q_D(QLocalSocket);
- d->readBufferMaxSize = size;
+ d->pipeReader->setMaxReadBufferSize(size);
}
bool QLocalSocket::waitForConnected(int msecs)
@@ -561,18 +382,10 @@ bool QLocalSocket::waitForDisconnected(int msecs)
qWarning("QLocalSocket::waitForDisconnected isn't supported for write only pipes.");
return false;
}
- QIncrementalSleepTimer timer(msecs);
- forever {
- d->checkPipeState();
- if (d->pipeClosed)
- close();
- if (state() == UnconnectedState)
- return true;
- Sleep(timer.nextSleepTime());
- if (timer.hasTimedOut())
- break;
+ if (d->pipeReader->waitForPipeClosed(msecs)) {
+ d->_q_pipeClosed();
+ return true;
}
-
return false;
}
@@ -593,28 +406,18 @@ bool QLocalSocket::waitForReadyRead(int msecs)
return false;
// We already know that the pipe is gone, but did not enter the event loop yet.
- if (d->pipeClosed) {
- close();
+ if (d->pipeReader->isPipeClosed()) {
+ d->_q_pipeClosed();
return false;
}
- Q_ASSERT(d->readSequenceStarted);
- DWORD result = WaitForSingleObject(d->overlapped.hEvent, msecs == -1 ? INFINITE : msecs);
- switch (result) {
- case WAIT_OBJECT_0:
- d->_q_notified();
- // We just noticed that the pipe is gone.
- if (d->pipeClosed) {
- close();
- return false;
- }
- return true;
- case WAIT_TIMEOUT:
- return false;
- }
+ bool result = d->pipeReader->waitForReadyRead(msecs);
- qWarning("QLocalSocket::waitForReadyRead WaitForSingleObject failed with error code %d.", int(GetLastError()));
- return false;
+ // We just noticed that the pipe is gone.
+ if (d->pipeReader->isPipeClosed())
+ d->_q_pipeClosed();
+
+ return result;
}
bool QLocalSocket::waitForBytesWritten(int msecs)
diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp
index 5e3e22a23e..cae2469328 100644
--- a/src/network/socket/qnativesocketengine.cpp
+++ b/src/network/socket/qnativesocketengine.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -414,7 +414,7 @@ bool QNativeSocketEngine::initialize(QAbstractSocket::SocketType socketType, QAb
If the socket type is either TCP or UDP, it is made non-blocking.
UDP sockets are also broadcast enabled.
*/
-bool QNativeSocketEngine::initialize(int socketDescriptor, QAbstractSocket::SocketState socketState)
+bool QNativeSocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState)
{
Q_D(QNativeSocketEngine);
@@ -471,7 +471,7 @@ bool QNativeSocketEngine::isValid() const
Returns the native socket descriptor. Any use of this descriptor
stands the risk of being non-portable.
*/
-int QNativeSocketEngine::socketDescriptor() const
+qintptr QNativeSocketEngine::socketDescriptor() const
{
Q_D(const QNativeSocketEngine);
return d->socketDescriptor;
@@ -1114,7 +1114,7 @@ bool QNativeSocketEngine::isReadNotificationEnabled() const
class QReadNotifier : public QSocketNotifier
{
public:
- QReadNotifier(int fd, QNativeSocketEngine *parent)
+ QReadNotifier(qintptr fd, QNativeSocketEngine *parent)
: QSocketNotifier(fd, QSocketNotifier::Read, parent)
{ engine = parent; }
diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h
index a024cd42d1..60c13c1258 100644
--- a/src/network/socket/qnativesocketengine_p.h
+++ b/src/network/socket/qnativesocketengine_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -113,9 +113,9 @@ public:
~QNativeSocketEngine();
bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol);
- bool initialize(int socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState);
+ bool initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState);
- int socketDescriptor() const;
+ qintptr socketDescriptor() const;
bool isValid() const;
@@ -199,7 +199,7 @@ public:
QNativeSocketEnginePrivate();
~QNativeSocketEnginePrivate();
- int socketDescriptor;
+ qintptr socketDescriptor;
QSocketNotifier *readNotifier, *writeNotifier, *exceptNotifier;
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 09aed255d6..324705d998 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -251,6 +251,12 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
n = IP_MULTICAST_LOOP;
}
break;
+ case QNativeSocketEngine::TypeOfServiceOption:
+ if (socketProtocol == QAbstractSocket::IPv4Protocol) {
+ level = IPPROTO_IP;
+ n = IP_TOS;
+ }
+ break;
}
int v = -1;
@@ -352,6 +358,12 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
n = IP_MULTICAST_LOOP;
}
break;
+ case QNativeSocketEngine::TypeOfServiceOption:
+ if (socketProtocol == QAbstractSocket::IPv4Protocol) {
+ level = IPPROTO_IP;
+ n = IP_TOS;
+ }
+ break;
}
return ::setsockopt(socketDescriptor, level, n, (char *) &v, sizeof(v)) == 0;
diff --git a/src/network/socket/qnativesocketengine_win.cpp b/src/network/socket/qnativesocketengine_win.cpp
index 247de01072..ee15702b76 100644
--- a/src/network/socket/qnativesocketengine_win.cpp
+++ b/src/network/socket/qnativesocketengine_win.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -229,7 +229,7 @@ void QNativeSocketEnginePrivate::setPortAndAddress(sockaddr_in * sockAddrIPv4, q
/*! \internal
*/
-static inline QAbstractSocket::SocketType qt_socket_getType(int socketDescriptor)
+static inline QAbstractSocket::SocketType qt_socket_getType(qintptr socketDescriptor)
{
int value = 0;
QT_SOCKLEN_T valueSize = sizeof(value);
@@ -247,7 +247,7 @@ static inline QAbstractSocket::SocketType qt_socket_getType(int socketDescriptor
/*! \internal
*/
-static inline int qt_socket_getMaxMsgSize(int socketDescriptor)
+static inline int qt_socket_getMaxMsgSize(qintptr socketDescriptor)
{
int value = 0;
QT_SOCKLEN_T valueSize = sizeof(value);
@@ -422,6 +422,9 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
n = IP_MULTICAST_LOOP;
}
break;
+ case QNativeSocketEngine::TypeOfServiceOption:
+ return -1;
+ break;
}
int v = -1;
@@ -502,6 +505,9 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
n = IP_MULTICAST_LOOP;
}
break;
+ case QNativeSocketEngine::TypeOfServiceOption:
+ return false;
+ break;
}
if (::setsockopt(socketDescriptor, level, n, (char*)&v, sizeof(v)) != 0) {
diff --git a/src/network/socket/qnet_unix_p.h b/src/network/socket/qnet_unix_p.h
index fe22c329e4..7b2ba54648 100644
--- a/src/network/socket/qnet_unix_p.h
+++ b/src/network/socket/qnet_unix_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp
index 5f510fa84b..919bdea2e0 100644
--- a/src/network/socket/qsocks5socketengine.cpp
+++ b/src/network/socket/qsocks5socketengine.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -332,9 +332,9 @@ public:
QSocks5BindStore();
~QSocks5BindStore();
- void add(int socketDescriptor, QSocks5BindData *bindData);
- bool contains(int socketDescriptor);
- QSocks5BindData *retrieve(int socketDescriptor);
+ void add(qintptr socketDescriptor, QSocks5BindData *bindData);
+ bool contains(qintptr socketDescriptor);
+ QSocks5BindData *retrieve(qintptr socketDescriptor);
protected:
void timerEvent(QTimerEvent * event);
@@ -360,7 +360,7 @@ QSocks5BindStore::~QSocks5BindStore()
{
}
-void QSocks5BindStore::add(int socketDescriptor, QSocks5BindData *bindData)
+void QSocks5BindStore::add(qintptr socketDescriptor, QSocks5BindData *bindData)
{
QMutexLocker lock(&mutex);
if (store.contains(socketDescriptor)) {
@@ -373,13 +373,13 @@ void QSocks5BindStore::add(int socketDescriptor, QSocks5BindData *bindData)
sweepTimerId = startTimer(60000);
}
-bool QSocks5BindStore::contains(int socketDescriptor)
+bool QSocks5BindStore::contains(qintptr socketDescriptor)
{
QMutexLocker lock(&mutex);
return store.contains(socketDescriptor);
}
-QSocks5BindData *QSocks5BindStore::retrieve(int socketDescriptor)
+QSocks5BindData *QSocks5BindStore::retrieve(qintptr socketDescriptor)
{
QMutexLocker lock(&mutex);
if (!store.contains(socketDescriptor))
@@ -1018,7 +1018,7 @@ bool QSocks5SocketEngine::initialize(QAbstractSocket::SocketType type, QAbstract
return true;
}
-bool QSocks5SocketEngine::initialize(int socketDescriptor, QAbstractSocket::SocketState socketState)
+bool QSocks5SocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState)
{
Q_D(QSocks5SocketEngine);
@@ -1080,7 +1080,7 @@ void QSocks5SocketEngine::setProxy(const QNetworkProxy &networkProxy)
d->proxyInfo = networkProxy;
}
-int QSocks5SocketEngine::socketDescriptor() const
+qintptr QSocks5SocketEngine::socketDescriptor() const
{
Q_D(const QSocks5SocketEngine);
return d->socketDescriptor;
@@ -1448,7 +1448,7 @@ int QSocks5SocketEngine::accept()
d->data->controlSocket->setParent(0);
d->bindData->localAddress = d->localAddress;
d->bindData->localPort = d->localPort;
- int sd = d->socketDescriptor;
+ qintptr sd = d->socketDescriptor;
socks5BindStore()->add(sd, d->bindData);
d->data = 0;
d->bindData = 0;
@@ -1917,7 +1917,7 @@ QSocks5SocketEngineHandler::createSocketEngine(QAbstractSocket::SocketType socke
return engine.take();
}
-QAbstractSocketEngine *QSocks5SocketEngineHandler::createSocketEngine(int socketDescriptor, QObject *parent)
+QAbstractSocketEngine *QSocks5SocketEngineHandler::createSocketEngine(qintptr socketDescriptor, QObject *parent)
{
QSOCKS5_DEBUG << "createSocketEngine" << socketDescriptor;
if (socks5BindStore()->contains(socketDescriptor)) {
diff --git a/src/network/socket/qsocks5socketengine_p.h b/src/network/socket/qsocks5socketengine_p.h
index 9b2f6e3ade..386e4856a1 100644
--- a/src/network/socket/qsocks5socketengine_p.h
+++ b/src/network/socket/qsocks5socketengine_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -70,11 +70,11 @@ public:
~QSocks5SocketEngine();
bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol);
- bool initialize(int socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState);
+ bool initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState = QAbstractSocket::ConnectedState);
void setProxy(const QNetworkProxy &networkProxy);
- int socketDescriptor() const;
+ qintptr socketDescriptor() const;
bool isValid() const;
@@ -261,7 +261,7 @@ public:
bool readNotificationEnabled, writeNotificationEnabled, exceptNotificationEnabled;
- int socketDescriptor;
+ qintptr socketDescriptor;
QSocks5Data *data;
QSocks5ConnectData *connectData;
@@ -290,7 +290,7 @@ class Q_AUTOTEST_EXPORT QSocks5SocketEngineHandler : public QSocketEngineHandler
public:
virtual QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType,
const QNetworkProxy &, QObject *parent);
- virtual QAbstractSocketEngine *createSocketEngine(int socketDescripter, QObject *parent);
+ virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescriptor, QObject *parent);
};
diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp
index 500d383e0f..857827facc 100644
--- a/src/network/socket/qtcpserver.cpp
+++ b/src/network/socket/qtcpserver.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -378,7 +378,7 @@ void QTcpServer::close()
\sa setSocketDescriptor(), isListening()
*/
-int QTcpServer::socketDescriptor() const
+qintptr QTcpServer::socketDescriptor() const
{
Q_D(const QTcpServer);
Q_CHECK_SOCKETENGINE(-1);
@@ -394,7 +394,7 @@ int QTcpServer::socketDescriptor() const
\sa socketDescriptor(), isListening()
*/
-bool QTcpServer::setSocketDescriptor(int socketDescriptor)
+bool QTcpServer::setSocketDescriptor(qintptr socketDescriptor)
{
Q_D(QTcpServer);
if (isListening()) {
@@ -566,7 +566,7 @@ QTcpSocket *QTcpServer::nextPendingConnection()
\sa newConnection(), nextPendingConnection(), addPendingConnection()
*/
-void QTcpServer::incomingConnection(int socketDescriptor)
+void QTcpServer::incomingConnection(qintptr socketDescriptor)
{
#if defined (QTCPSERVER_DEBUG)
qDebug("QTcpServer::incomingConnection(%i)", socketDescriptor);
diff --git a/src/network/socket/qtcpserver.h b/src/network/socket/qtcpserver.h
index 2fe090af32..a322294f58 100644
--- a/src/network/socket/qtcpserver.h
+++ b/src/network/socket/qtcpserver.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -76,8 +76,8 @@ public:
quint16 serverPort() const;
QHostAddress serverAddress() const;
- int socketDescriptor() const;
- bool setSocketDescriptor(int socketDescriptor);
+ qintptr socketDescriptor() const;
+ bool setSocketDescriptor(qintptr socketDescriptor);
bool waitForNewConnection(int msec = 0, bool *timedOut = 0);
virtual bool hasPendingConnections() const;
@@ -92,7 +92,7 @@ public:
#endif
protected:
- virtual void incomingConnection(int handle);
+ virtual void incomingConnection(qintptr handle);
void addPendingConnection(QTcpSocket* socket);
Q_SIGNALS:
diff --git a/src/network/socket/qtcpsocket.cpp b/src/network/socket/qtcpsocket.cpp
index 78fb4cd050..f900ca752c 100644
--- a/src/network/socket/qtcpsocket.cpp
+++ b/src/network/socket/qtcpsocket.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -60,7 +60,7 @@
\bold{Note:} TCP sockets cannot be opened in QIODevice::Unbuffered mode.
- \sa QTcpServer, QUdpSocket, QFtp, QNetworkAccessManager,
+ \sa QTcpServer, QUdpSocket, QNetworkAccessManager,
{Fortune Server Example}, {Fortune Client Example},
{Threaded Fortune Server Example}, {Blocking Fortune Client Example},
{Loopback Example}, {Torrent Example}
diff --git a/src/network/socket/qtcpsocket.h b/src/network/socket/qtcpsocket.h
index 8323836a54..aa2e89d840 100644
--- a/src/network/socket/qtcpsocket.h
+++ b/src/network/socket/qtcpsocket.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/network/socket/qtcpsocket_p.h b/src/network/socket/qtcpsocket_p.h
index 1ecc274fcd..33672539cc 100644
--- a/src/network/socket/qtcpsocket_p.h
+++ b/src/network/socket/qtcpsocket_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/network/socket/qudpsocket.cpp b/src/network/socket/qudpsocket.cpp
index e12034d86b..f378fea7b9 100644
--- a/src/network/socket/qudpsocket.cpp
+++ b/src/network/socket/qudpsocket.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
diff --git a/src/network/socket/qudpsocket.h b/src/network/socket/qudpsocket.h
index 068c20b9c4..ed5f539732 100644
--- a/src/network/socket/qudpsocket.h
+++ b/src/network/socket/qudpsocket.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**