Make socket descriptors qintptr.
Windows x64 uses 64 bits integer for sockets, to ensure compatibility we should use ptr sized integers for our socket descriptors. Task-number: QTBUG-19004 Change-Id: I4b56023874a4f1bad107c66c054fecfedde33d88 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
This commit is contained in:
parent
eb0ce0d5c1
commit
bf7f170607
@ -900,6 +900,7 @@ template <> struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qin
|
|||||||
template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
|
template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { };
|
||||||
typedef QIntegerForSizeof<void*>::Unsigned quintptr;
|
typedef QIntegerForSizeof<void*>::Unsigned quintptr;
|
||||||
typedef QIntegerForSizeof<void*>::Signed qptrdiff;
|
typedef QIntegerForSizeof<void*>::Signed qptrdiff;
|
||||||
|
typedef qptrdiff qintptr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Useful type definitions for Qt
|
Useful type definitions for Qt
|
||||||
|
@ -168,7 +168,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
\sa setEnabled(), isEnabled()
|
\sa setEnabled(), isEnabled()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QSocketNotifier::QSocketNotifier(int socket, Type type, QObject *parent)
|
QSocketNotifier::QSocketNotifier(qintptr socket, Type type, QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
if (socket < 0)
|
if (socket < 0)
|
||||||
|
@ -58,7 +58,7 @@ class Q_CORE_EXPORT QSocketNotifier : public QObject
|
|||||||
public:
|
public:
|
||||||
enum Type { Read, Write, Exception };
|
enum Type { Read, Write, Exception };
|
||||||
|
|
||||||
QSocketNotifier(int socket, Type, QObject *parent = 0);
|
QSocketNotifier(qintptr socket, Type, QObject *parent = 0);
|
||||||
~QSocketNotifier();
|
~QSocketNotifier();
|
||||||
|
|
||||||
inline int socket() const { return sockfd; }
|
inline int socket() const { return sockfd; }
|
||||||
@ -78,7 +78,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QSocketNotifier)
|
Q_DISABLE_COPY(QSocketNotifier)
|
||||||
|
|
||||||
int sockfd;
|
qintptr sockfd;
|
||||||
Type sntype;
|
Type sntype;
|
||||||
bool snenabled;
|
bool snenabled;
|
||||||
};
|
};
|
||||||
|
@ -1723,7 +1723,7 @@ bool QAbstractSocket::canReadLine() const
|
|||||||
|
|
||||||
\sa setSocketDescriptor()
|
\sa setSocketDescriptor()
|
||||||
*/
|
*/
|
||||||
int QAbstractSocket::socketDescriptor() const
|
qintptr QAbstractSocket::socketDescriptor() const
|
||||||
{
|
{
|
||||||
Q_D(const QAbstractSocket);
|
Q_D(const QAbstractSocket);
|
||||||
return d->cachedSocketDescriptor;
|
return d->cachedSocketDescriptor;
|
||||||
@ -1741,7 +1741,7 @@ int QAbstractSocket::socketDescriptor() const
|
|||||||
|
|
||||||
\sa socketDescriptor()
|
\sa socketDescriptor()
|
||||||
*/
|
*/
|
||||||
bool QAbstractSocket::setSocketDescriptor(int socketDescriptor, SocketState socketState,
|
bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState socketState,
|
||||||
OpenMode openMode)
|
OpenMode openMode)
|
||||||
{
|
{
|
||||||
Q_D(QAbstractSocket);
|
Q_D(QAbstractSocket);
|
||||||
|
@ -156,8 +156,8 @@ public:
|
|||||||
void abort();
|
void abort();
|
||||||
|
|
||||||
// ### Qt 5: Make socketDescriptor() and setSocketDescriptor() virtual.
|
// ### Qt 5: Make socketDescriptor() and setSocketDescriptor() virtual.
|
||||||
int socketDescriptor() const;
|
qintptr socketDescriptor() const;
|
||||||
bool setSocketDescriptor(int socketDescriptor, SocketState state = ConnectedState,
|
bool setSocketDescriptor(qintptr socketDescriptor, SocketState state = ConnectedState,
|
||||||
OpenMode openMode = ReadWrite);
|
OpenMode openMode = ReadWrite);
|
||||||
|
|
||||||
// ### Qt 5: Make virtual?
|
// ### Qt 5: Make virtual?
|
||||||
|
@ -118,7 +118,7 @@ public:
|
|||||||
QString peerName;
|
QString peerName;
|
||||||
|
|
||||||
QAbstractSocketEngine *socketEngine;
|
QAbstractSocketEngine *socketEngine;
|
||||||
int cachedSocketDescriptor;
|
qintptr cachedSocketDescriptor;
|
||||||
|
|
||||||
#ifndef QT_NO_NETWORKPROXY
|
#ifndef QT_NO_NETWORKPROXY
|
||||||
QNetworkProxy proxy;
|
QNetworkProxy proxy;
|
||||||
|
@ -118,7 +118,7 @@ QAbstractSocketEngine *QAbstractSocketEngine::createSocketEngine(QAbstractSocket
|
|||||||
return new QNativeSocketEngine(parent);
|
return new QNativeSocketEngine(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
QAbstractSocketEngine *QAbstractSocketEngine::createSocketEngine(int socketDescripter, QObject *parent)
|
QAbstractSocketEngine *QAbstractSocketEngine::createSocketEngine(qintptr socketDescripter, QObject *parent)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&socketHandlers()->mutex);
|
QMutexLocker locker(&socketHandlers()->mutex);
|
||||||
for (int i = 0; i < socketHandlers()->size(); i++) {
|
for (int i = 0; i < socketHandlers()->size(); i++) {
|
||||||
|
@ -84,7 +84,7 @@ class Q_AUTOTEST_EXPORT QAbstractSocketEngine : public QObject
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
static QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType, const QNetworkProxy &, QObject *parent);
|
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);
|
QAbstractSocketEngine(QObject *parent = 0);
|
||||||
|
|
||||||
@ -105,9 +105,9 @@ public:
|
|||||||
|
|
||||||
virtual bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol) = 0;
|
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;
|
virtual bool isValid() const = 0;
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ protected:
|
|||||||
virtual ~QSocketEngineHandler();
|
virtual ~QSocketEngineHandler();
|
||||||
virtual QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType,
|
virtual QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType,
|
||||||
const QNetworkProxy &, QObject *parent) = 0;
|
const QNetworkProxy &, QObject *parent) = 0;
|
||||||
virtual QAbstractSocketEngine *createSocketEngine(int socketDescripter, QObject *parent) = 0;
|
virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescriptor, QObject *parent) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class QAbstractSocketEngine;
|
friend class QAbstractSocketEngine;
|
||||||
|
@ -103,7 +103,7 @@ bool QHttpSocketEngine::initialize(QAbstractSocket::SocketType type, QAbstractSo
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QHttpSocketEngine::initialize(int, QAbstractSocket::SocketState)
|
bool QHttpSocketEngine::initialize(qintptr, QAbstractSocket::SocketState)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ void QHttpSocketEngine::setProxy(const QNetworkProxy &proxy)
|
|||||||
d->authenticator.setPassword(password);
|
d->authenticator.setPassword(password);
|
||||||
}
|
}
|
||||||
|
|
||||||
int QHttpSocketEngine::socketDescriptor() const
|
qintptr QHttpSocketEngine::socketDescriptor() const
|
||||||
{
|
{
|
||||||
Q_D(const QHttpSocketEngine);
|
Q_D(const QHttpSocketEngine);
|
||||||
return d->socket ? d->socket->socketDescriptor() : 0;
|
return d->socket ? d->socket->socketDescriptor() : 0;
|
||||||
@ -838,7 +838,7 @@ QAbstractSocketEngine *QHttpSocketEngineHandler::createSocketEngine(QAbstractSoc
|
|||||||
return engine;
|
return engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
QAbstractSocketEngine *QHttpSocketEngineHandler::createSocketEngine(int, QObject *)
|
QAbstractSocketEngine *QHttpSocketEngineHandler::createSocketEngine(qintptr, QObject *)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -80,11 +80,11 @@ public:
|
|||||||
~QHttpSocketEngine();
|
~QHttpSocketEngine();
|
||||||
|
|
||||||
bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol);
|
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);
|
void setProxy(const QNetworkProxy &networkProxy);
|
||||||
|
|
||||||
int socketDescriptor() const;
|
qintptr socketDescriptor() const;
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ class Q_AUTOTEST_EXPORT QHttpSocketEngineHandler : public QSocketEngineHandler
|
|||||||
public:
|
public:
|
||||||
virtual QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType,
|
virtual QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType,
|
||||||
const QNetworkProxy &, QObject *parent);
|
const QNetworkProxy &, QObject *parent);
|
||||||
virtual QAbstractSocketEngine *createSocketEngine(int socketDescripter, QObject *parent);
|
virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescripter, QObject *parent);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -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.
|
If the socket type is either TCP or UDP, it is made non-blocking.
|
||||||
UDP sockets are also broadcast enabled.
|
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);
|
Q_D(QNativeSocketEngine);
|
||||||
|
|
||||||
@ -471,7 +471,7 @@ bool QNativeSocketEngine::isValid() const
|
|||||||
Returns the native socket descriptor. Any use of this descriptor
|
Returns the native socket descriptor. Any use of this descriptor
|
||||||
stands the risk of being non-portable.
|
stands the risk of being non-portable.
|
||||||
*/
|
*/
|
||||||
int QNativeSocketEngine::socketDescriptor() const
|
qintptr QNativeSocketEngine::socketDescriptor() const
|
||||||
{
|
{
|
||||||
Q_D(const QNativeSocketEngine);
|
Q_D(const QNativeSocketEngine);
|
||||||
return d->socketDescriptor;
|
return d->socketDescriptor;
|
||||||
@ -1114,7 +1114,7 @@ bool QNativeSocketEngine::isReadNotificationEnabled() const
|
|||||||
class QReadNotifier : public QSocketNotifier
|
class QReadNotifier : public QSocketNotifier
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QReadNotifier(int fd, QNativeSocketEngine *parent)
|
QReadNotifier(qintptr fd, QNativeSocketEngine *parent)
|
||||||
: QSocketNotifier(fd, QSocketNotifier::Read, parent)
|
: QSocketNotifier(fd, QSocketNotifier::Read, parent)
|
||||||
{ engine = parent; }
|
{ engine = parent; }
|
||||||
|
|
||||||
|
@ -113,9 +113,9 @@ public:
|
|||||||
~QNativeSocketEngine();
|
~QNativeSocketEngine();
|
||||||
|
|
||||||
bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol);
|
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;
|
bool isValid() const;
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ public:
|
|||||||
QNativeSocketEnginePrivate();
|
QNativeSocketEnginePrivate();
|
||||||
~QNativeSocketEnginePrivate();
|
~QNativeSocketEnginePrivate();
|
||||||
|
|
||||||
int socketDescriptor;
|
qintptr socketDescriptor;
|
||||||
|
|
||||||
QSocketNotifier *readNotifier, *writeNotifier, *exceptNotifier;
|
QSocketNotifier *readNotifier, *writeNotifier, *exceptNotifier;
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ void QNativeSocketEnginePrivate::setPortAndAddress(sockaddr_in * sockAddrIPv4, q
|
|||||||
/*! \internal
|
/*! \internal
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static inline QAbstractSocket::SocketType qt_socket_getType(int socketDescriptor)
|
static inline QAbstractSocket::SocketType qt_socket_getType(qintptr socketDescriptor)
|
||||||
{
|
{
|
||||||
int value = 0;
|
int value = 0;
|
||||||
QT_SOCKLEN_T valueSize = sizeof(value);
|
QT_SOCKLEN_T valueSize = sizeof(value);
|
||||||
@ -247,7 +247,7 @@ static inline QAbstractSocket::SocketType qt_socket_getType(int socketDescriptor
|
|||||||
/*! \internal
|
/*! \internal
|
||||||
|
|
||||||
*/
|
*/
|
||||||
static inline int qt_socket_getMaxMsgSize(int socketDescriptor)
|
static inline int qt_socket_getMaxMsgSize(qintptr socketDescriptor)
|
||||||
{
|
{
|
||||||
int value = 0;
|
int value = 0;
|
||||||
QT_SOCKLEN_T valueSize = sizeof(value);
|
QT_SOCKLEN_T valueSize = sizeof(value);
|
||||||
|
@ -332,9 +332,9 @@ public:
|
|||||||
QSocks5BindStore();
|
QSocks5BindStore();
|
||||||
~QSocks5BindStore();
|
~QSocks5BindStore();
|
||||||
|
|
||||||
void add(int socketDescriptor, QSocks5BindData *bindData);
|
void add(qintptr socketDescriptor, QSocks5BindData *bindData);
|
||||||
bool contains(int socketDescriptor);
|
bool contains(qintptr socketDescriptor);
|
||||||
QSocks5BindData *retrieve(int socketDescriptor);
|
QSocks5BindData *retrieve(qintptr socketDescriptor);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void timerEvent(QTimerEvent * event);
|
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);
|
QMutexLocker lock(&mutex);
|
||||||
if (store.contains(socketDescriptor)) {
|
if (store.contains(socketDescriptor)) {
|
||||||
@ -373,13 +373,13 @@ void QSocks5BindStore::add(int socketDescriptor, QSocks5BindData *bindData)
|
|||||||
sweepTimerId = startTimer(60000);
|
sweepTimerId = startTimer(60000);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QSocks5BindStore::contains(int socketDescriptor)
|
bool QSocks5BindStore::contains(qintptr socketDescriptor)
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&mutex);
|
QMutexLocker lock(&mutex);
|
||||||
return store.contains(socketDescriptor);
|
return store.contains(socketDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
QSocks5BindData *QSocks5BindStore::retrieve(int socketDescriptor)
|
QSocks5BindData *QSocks5BindStore::retrieve(qintptr socketDescriptor)
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&mutex);
|
QMutexLocker lock(&mutex);
|
||||||
if (!store.contains(socketDescriptor))
|
if (!store.contains(socketDescriptor))
|
||||||
@ -1018,7 +1018,7 @@ bool QSocks5SocketEngine::initialize(QAbstractSocket::SocketType type, QAbstract
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QSocks5SocketEngine::initialize(int socketDescriptor, QAbstractSocket::SocketState socketState)
|
bool QSocks5SocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket::SocketState socketState)
|
||||||
{
|
{
|
||||||
Q_D(QSocks5SocketEngine);
|
Q_D(QSocks5SocketEngine);
|
||||||
|
|
||||||
@ -1080,7 +1080,7 @@ void QSocks5SocketEngine::setProxy(const QNetworkProxy &networkProxy)
|
|||||||
d->proxyInfo = networkProxy;
|
d->proxyInfo = networkProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QSocks5SocketEngine::socketDescriptor() const
|
qintptr QSocks5SocketEngine::socketDescriptor() const
|
||||||
{
|
{
|
||||||
Q_D(const QSocks5SocketEngine);
|
Q_D(const QSocks5SocketEngine);
|
||||||
return d->socketDescriptor;
|
return d->socketDescriptor;
|
||||||
@ -1448,7 +1448,7 @@ int QSocks5SocketEngine::accept()
|
|||||||
d->data->controlSocket->setParent(0);
|
d->data->controlSocket->setParent(0);
|
||||||
d->bindData->localAddress = d->localAddress;
|
d->bindData->localAddress = d->localAddress;
|
||||||
d->bindData->localPort = d->localPort;
|
d->bindData->localPort = d->localPort;
|
||||||
int sd = d->socketDescriptor;
|
qintptr sd = d->socketDescriptor;
|
||||||
socks5BindStore()->add(sd, d->bindData);
|
socks5BindStore()->add(sd, d->bindData);
|
||||||
d->data = 0;
|
d->data = 0;
|
||||||
d->bindData = 0;
|
d->bindData = 0;
|
||||||
@ -1917,7 +1917,7 @@ QSocks5SocketEngineHandler::createSocketEngine(QAbstractSocket::SocketType socke
|
|||||||
return engine.take();
|
return engine.take();
|
||||||
}
|
}
|
||||||
|
|
||||||
QAbstractSocketEngine *QSocks5SocketEngineHandler::createSocketEngine(int socketDescriptor, QObject *parent)
|
QAbstractSocketEngine *QSocks5SocketEngineHandler::createSocketEngine(qintptr socketDescriptor, QObject *parent)
|
||||||
{
|
{
|
||||||
QSOCKS5_DEBUG << "createSocketEngine" << socketDescriptor;
|
QSOCKS5_DEBUG << "createSocketEngine" << socketDescriptor;
|
||||||
if (socks5BindStore()->contains(socketDescriptor)) {
|
if (socks5BindStore()->contains(socketDescriptor)) {
|
||||||
|
@ -70,11 +70,11 @@ public:
|
|||||||
~QSocks5SocketEngine();
|
~QSocks5SocketEngine();
|
||||||
|
|
||||||
bool initialize(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol = QAbstractSocket::IPv4Protocol);
|
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);
|
void setProxy(const QNetworkProxy &networkProxy);
|
||||||
|
|
||||||
int socketDescriptor() const;
|
qintptr socketDescriptor() const;
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
|
||||||
@ -261,7 +261,7 @@ public:
|
|||||||
|
|
||||||
bool readNotificationEnabled, writeNotificationEnabled, exceptNotificationEnabled;
|
bool readNotificationEnabled, writeNotificationEnabled, exceptNotificationEnabled;
|
||||||
|
|
||||||
int socketDescriptor;
|
qintptr socketDescriptor;
|
||||||
|
|
||||||
QSocks5Data *data;
|
QSocks5Data *data;
|
||||||
QSocks5ConnectData *connectData;
|
QSocks5ConnectData *connectData;
|
||||||
@ -290,7 +290,7 @@ class Q_AUTOTEST_EXPORT QSocks5SocketEngineHandler : public QSocketEngineHandler
|
|||||||
public:
|
public:
|
||||||
virtual QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType,
|
virtual QAbstractSocketEngine *createSocketEngine(QAbstractSocket::SocketType socketType,
|
||||||
const QNetworkProxy &, QObject *parent);
|
const QNetworkProxy &, QObject *parent);
|
||||||
virtual QAbstractSocketEngine *createSocketEngine(int socketDescripter, QObject *parent);
|
virtual QAbstractSocketEngine *createSocketEngine(qintptr socketDescriptor, QObject *parent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -378,7 +378,7 @@ void QTcpServer::close()
|
|||||||
|
|
||||||
\sa setSocketDescriptor(), isListening()
|
\sa setSocketDescriptor(), isListening()
|
||||||
*/
|
*/
|
||||||
int QTcpServer::socketDescriptor() const
|
qintptr QTcpServer::socketDescriptor() const
|
||||||
{
|
{
|
||||||
Q_D(const QTcpServer);
|
Q_D(const QTcpServer);
|
||||||
Q_CHECK_SOCKETENGINE(-1);
|
Q_CHECK_SOCKETENGINE(-1);
|
||||||
@ -394,7 +394,7 @@ int QTcpServer::socketDescriptor() const
|
|||||||
|
|
||||||
\sa socketDescriptor(), isListening()
|
\sa socketDescriptor(), isListening()
|
||||||
*/
|
*/
|
||||||
bool QTcpServer::setSocketDescriptor(int socketDescriptor)
|
bool QTcpServer::setSocketDescriptor(qintptr socketDescriptor)
|
||||||
{
|
{
|
||||||
Q_D(QTcpServer);
|
Q_D(QTcpServer);
|
||||||
if (isListening()) {
|
if (isListening()) {
|
||||||
@ -566,7 +566,7 @@ QTcpSocket *QTcpServer::nextPendingConnection()
|
|||||||
|
|
||||||
\sa newConnection(), nextPendingConnection(), addPendingConnection()
|
\sa newConnection(), nextPendingConnection(), addPendingConnection()
|
||||||
*/
|
*/
|
||||||
void QTcpServer::incomingConnection(int socketDescriptor)
|
void QTcpServer::incomingConnection(qintptr socketDescriptor)
|
||||||
{
|
{
|
||||||
#if defined (QTCPSERVER_DEBUG)
|
#if defined (QTCPSERVER_DEBUG)
|
||||||
qDebug("QTcpServer::incomingConnection(%i)", socketDescriptor);
|
qDebug("QTcpServer::incomingConnection(%i)", socketDescriptor);
|
||||||
|
@ -76,8 +76,8 @@ public:
|
|||||||
quint16 serverPort() const;
|
quint16 serverPort() const;
|
||||||
QHostAddress serverAddress() const;
|
QHostAddress serverAddress() const;
|
||||||
|
|
||||||
int socketDescriptor() const;
|
qintptr socketDescriptor() const;
|
||||||
bool setSocketDescriptor(int socketDescriptor);
|
bool setSocketDescriptor(qintptr socketDescriptor);
|
||||||
|
|
||||||
bool waitForNewConnection(int msec = 0, bool *timedOut = 0);
|
bool waitForNewConnection(int msec = 0, bool *timedOut = 0);
|
||||||
virtual bool hasPendingConnections() const;
|
virtual bool hasPendingConnections() const;
|
||||||
@ -92,7 +92,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void incomingConnection(int handle);
|
virtual void incomingConnection(qintptr handle);
|
||||||
void addPendingConnection(QTcpSocket* socket);
|
void addPendingConnection(QTcpSocket* socket);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
@ -455,7 +455,7 @@ void QSslSocket::connectToHostEncrypted(const QString &hostName, quint16 port,
|
|||||||
|
|
||||||
\sa socketDescriptor()
|
\sa socketDescriptor()
|
||||||
*/
|
*/
|
||||||
bool QSslSocket::setSocketDescriptor(int socketDescriptor, SocketState state, OpenMode openMode)
|
bool QSslSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState state, OpenMode openMode)
|
||||||
{
|
{
|
||||||
Q_D(QSslSocket);
|
Q_D(QSslSocket);
|
||||||
#ifdef QSSLSOCKET_DEBUG
|
#ifdef QSSLSOCKET_DEBUG
|
||||||
|
@ -87,7 +87,7 @@ public:
|
|||||||
// Autostarting the SSL client handshake.
|
// Autostarting the SSL client handshake.
|
||||||
void connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
|
void connectToHostEncrypted(const QString &hostName, quint16 port, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
|
||||||
void connectToHostEncrypted(const QString &hostName, quint16 port, const QString &sslPeerName, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
|
void connectToHostEncrypted(const QString &hostName, quint16 port, const QString &sslPeerName, OpenMode mode = ReadWrite, NetworkLayerProtocol protocol = AnyIPProtocol);
|
||||||
bool setSocketDescriptor(int socketDescriptor, SocketState state = ConnectedState,
|
bool setSocketDescriptor(qintptr socketDescriptor, SocketState state = ConnectedState,
|
||||||
OpenMode openMode = ReadWrite);
|
OpenMode openMode = ReadWrite);
|
||||||
|
|
||||||
// ### Qt 5: Make virtual
|
// ### Qt 5: Make virtual
|
||||||
|
@ -264,7 +264,7 @@ void tst_QLocalSocket::socket_basic()
|
|||||||
QCOMPARE(socket.isValid(), false);
|
QCOMPARE(socket.isValid(), false);
|
||||||
QVERIFY(socket.readBufferSize() == 0);
|
QVERIFY(socket.readBufferSize() == 0);
|
||||||
socket.setReadBufferSize(0);
|
socket.setReadBufferSize(0);
|
||||||
//QCOMPARE(socket.socketDescriptor(), -1);
|
//QCOMPARE(socket.socketDescriptor(), (qintptr)-1);
|
||||||
QCOMPARE(socket.state(), QLocalSocket::UnconnectedState);
|
QCOMPARE(socket.state(), QLocalSocket::UnconnectedState);
|
||||||
QCOMPARE(socket.waitForConnected(0), false);
|
QCOMPARE(socket.waitForConnected(0), false);
|
||||||
QCOMPARE(socket.waitForDisconnected(0), false);
|
QCOMPARE(socket.waitForDisconnected(0), false);
|
||||||
@ -632,7 +632,7 @@ void tst_QLocalSocket::hitMaximumConnections()
|
|||||||
void tst_QLocalSocket::setSocketDescriptor()
|
void tst_QLocalSocket::setSocketDescriptor()
|
||||||
{
|
{
|
||||||
LocalSocket socket;
|
LocalSocket socket;
|
||||||
quintptr minusOne = -1;
|
qintptr minusOne = -1;
|
||||||
socket.setSocketDescriptor(minusOne, QLocalSocket::ConnectingState, QIODevice::Append);
|
socket.setSocketDescriptor(minusOne, QLocalSocket::ConnectingState, QIODevice::Append);
|
||||||
QCOMPARE(socket.socketDescriptor(), minusOne);
|
QCOMPARE(socket.socketDescriptor(), minusOne);
|
||||||
QCOMPARE(socket.state(), QLocalSocket::ConnectingState);
|
QCOMPARE(socket.state(), QLocalSocket::ConnectingState);
|
||||||
|
@ -191,7 +191,7 @@ void tst_QTcpServer::constructing()
|
|||||||
QCOMPARE(socket.serverAddress(), QHostAddress());
|
QCOMPARE(socket.serverAddress(), QHostAddress());
|
||||||
QCOMPARE(socket.maxPendingConnections(), 30);
|
QCOMPARE(socket.maxPendingConnections(), 30);
|
||||||
QCOMPARE(socket.hasPendingConnections(), false);
|
QCOMPARE(socket.hasPendingConnections(), false);
|
||||||
QCOMPARE(socket.socketDescriptor(), -1);
|
QCOMPARE(socket.socketDescriptor(), (qintptr)-1);
|
||||||
QCOMPARE(socket.serverError(), QAbstractSocket::UnknownSocketError);
|
QCOMPARE(socket.serverError(), QAbstractSocket::UnknownSocketError);
|
||||||
|
|
||||||
// Check the state of the socket layer?
|
// Check the state of the socket layer?
|
||||||
@ -510,7 +510,7 @@ public:
|
|||||||
bool ok;
|
bool ok;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void incomingConnection(int socketDescriptor)
|
void incomingConnection(qintptr socketDescriptor)
|
||||||
{
|
{
|
||||||
// how a user woulddo it (qabstractsocketengine is not public)
|
// how a user woulddo it (qabstractsocketengine is not public)
|
||||||
unsigned long arg = 0;
|
unsigned long arg = 0;
|
||||||
|
@ -458,7 +458,7 @@ void tst_QTcpSocket::constructing()
|
|||||||
QCOMPARE((int) socket->bytesAvailable(), 0);
|
QCOMPARE((int) socket->bytesAvailable(), 0);
|
||||||
QCOMPARE(socket->canReadLine(), false);
|
QCOMPARE(socket->canReadLine(), false);
|
||||||
QCOMPARE(socket->readLine(), QByteArray());
|
QCOMPARE(socket->readLine(), QByteArray());
|
||||||
QCOMPARE(socket->socketDescriptor(), -1);
|
QCOMPARE(socket->socketDescriptor(), (qintptr)-1);
|
||||||
QCOMPARE((int) socket->localPort(), 0);
|
QCOMPARE((int) socket->localPort(), 0);
|
||||||
QVERIFY(socket->localAddress() == QHostAddress());
|
QVERIFY(socket->localAddress() == QHostAddress());
|
||||||
QCOMPARE((int) socket->peerPort(), 0);
|
QCOMPARE((int) socket->peerPort(), 0);
|
||||||
@ -538,9 +538,9 @@ void tst_QTcpSocket::bind()
|
|||||||
void tst_QTcpSocket::setInvalidSocketDescriptor()
|
void tst_QTcpSocket::setInvalidSocketDescriptor()
|
||||||
{
|
{
|
||||||
QTcpSocket *socket = newSocket();
|
QTcpSocket *socket = newSocket();
|
||||||
QCOMPARE(socket->socketDescriptor(), -1);
|
QCOMPARE(socket->socketDescriptor(), (qintptr)-1);
|
||||||
QVERIFY(!socket->setSocketDescriptor(-5, QTcpSocket::UnconnectedState));
|
QVERIFY(!socket->setSocketDescriptor(-5, QTcpSocket::UnconnectedState));
|
||||||
QCOMPARE(socket->socketDescriptor(), -1);
|
QCOMPARE(socket->socketDescriptor(), (qintptr)-1);
|
||||||
|
|
||||||
QCOMPARE(socket->error(), QTcpSocket::UnsupportedSocketOperationError);
|
QCOMPARE(socket->error(), QTcpSocket::UnsupportedSocketOperationError);
|
||||||
|
|
||||||
@ -577,17 +577,17 @@ void tst_QTcpSocket::setSocketDescriptor()
|
|||||||
QVERIFY(sock != INVALID_SOCKET);
|
QVERIFY(sock != INVALID_SOCKET);
|
||||||
QTcpSocket *socket = newSocket();
|
QTcpSocket *socket = newSocket();
|
||||||
QVERIFY(socket->setSocketDescriptor(sock, QTcpSocket::UnconnectedState));
|
QVERIFY(socket->setSocketDescriptor(sock, QTcpSocket::UnconnectedState));
|
||||||
QCOMPARE(socket->socketDescriptor(), (int)sock);
|
QCOMPARE(socket->socketDescriptor(), (qintptr)sock);
|
||||||
|
|
||||||
qt_qhostinfo_clear_cache(); //avoid the HostLookupState being skipped due to address being in cache from previous test.
|
qt_qhostinfo_clear_cache(); //avoid the HostLookupState being skipped due to address being in cache from previous test.
|
||||||
socket->connectToHost(QtNetworkSettings::serverName(), 143);
|
socket->connectToHost(QtNetworkSettings::serverName(), 143);
|
||||||
QCOMPARE(socket->state(), QTcpSocket::HostLookupState);
|
QCOMPARE(socket->state(), QTcpSocket::HostLookupState);
|
||||||
QCOMPARE(socket->socketDescriptor(), (int)sock);
|
QCOMPARE(socket->socketDescriptor(), (qintptr)sock);
|
||||||
QVERIFY(socket->waitForConnected(10000));
|
QVERIFY(socket->waitForConnected(10000));
|
||||||
// skip this, it has been broken for years, see task 260735
|
// skip this, it has been broken for years, see task 260735
|
||||||
// if somebody complains, consider fixing it, but it might break existing applications.
|
// if somebody complains, consider fixing it, but it might break existing applications.
|
||||||
QEXPECT_FAIL("", "bug has been around for years, will not fix without need", Continue);
|
QEXPECT_FAIL("", "bug has been around for years, will not fix without need", Continue);
|
||||||
QCOMPARE(socket->socketDescriptor(), (int)sock);
|
QCOMPARE(socket->socketDescriptor(), (qintptr)sock);
|
||||||
delete socket;
|
delete socket;
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
delete dummy;
|
delete dummy;
|
||||||
@ -600,7 +600,7 @@ void tst_QTcpSocket::socketDescriptor()
|
|||||||
{
|
{
|
||||||
QTcpSocket *socket = newSocket();
|
QTcpSocket *socket = newSocket();
|
||||||
|
|
||||||
QCOMPARE(socket->socketDescriptor(), -1);
|
QCOMPARE(socket->socketDescriptor(), (qintptr)-1);
|
||||||
socket->connectToHost(QtNetworkSettings::serverName(), 143);
|
socket->connectToHost(QtNetworkSettings::serverName(), 143);
|
||||||
QVERIFY((socket->state() == QAbstractSocket::HostLookupState && socket->socketDescriptor() == -1) ||
|
QVERIFY((socket->state() == QAbstractSocket::HostLookupState && socket->socketDescriptor() == -1) ||
|
||||||
(socket->state() == QAbstractSocket::ConnectingState && socket->socketDescriptor() != -1));
|
(socket->state() == QAbstractSocket::ConnectingState && socket->socketDescriptor() != -1));
|
||||||
@ -1025,7 +1025,7 @@ void tst_QTcpSocket::openCloseOpenClose()
|
|||||||
QCOMPARE((int) socket->bytesAvailable(), 0);
|
QCOMPARE((int) socket->bytesAvailable(), 0);
|
||||||
QCOMPARE(socket->canReadLine(), false);
|
QCOMPARE(socket->canReadLine(), false);
|
||||||
QCOMPARE(socket->readLine(), QByteArray());
|
QCOMPARE(socket->readLine(), QByteArray());
|
||||||
QCOMPARE(socket->socketDescriptor(), -1);
|
QCOMPARE(socket->socketDescriptor(), (qintptr)-1);
|
||||||
QCOMPARE((int) socket->localPort(), 0);
|
QCOMPARE((int) socket->localPort(), 0);
|
||||||
QVERIFY(socket->localAddress() == QHostAddress());
|
QVERIFY(socket->localAddress() == QHostAddress());
|
||||||
QCOMPARE((int) socket->peerPort(), 0);
|
QCOMPARE((int) socket->peerPort(), 0);
|
||||||
|
@ -195,7 +195,7 @@ void tst_QUdpSocket::constructing()
|
|||||||
QCOMPARE((int) socket.bytesAvailable(), 0);
|
QCOMPARE((int) socket.bytesAvailable(), 0);
|
||||||
QCOMPARE(socket.canReadLine(), false);
|
QCOMPARE(socket.canReadLine(), false);
|
||||||
QCOMPARE(socket.readLine(), QByteArray());
|
QCOMPARE(socket.readLine(), QByteArray());
|
||||||
QCOMPARE(socket.socketDescriptor(), -1);
|
QCOMPARE(socket.socketDescriptor(), (qintptr)-1);
|
||||||
QCOMPARE(socket.error(), QUdpSocket::UnknownSocketError);
|
QCOMPARE(socket.error(), QUdpSocket::UnknownSocketError);
|
||||||
QCOMPARE(socket.errorString(), QString("Unknown error"));
|
QCOMPARE(socket.errorString(), QString("Unknown error"));
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ void tst_QSslSocket::constructing()
|
|||||||
QCOMPARE(socket.peerPort(), quint16(0));
|
QCOMPARE(socket.peerPort(), quint16(0));
|
||||||
QCOMPARE(socket.proxy().type(), QNetworkProxy::DefaultProxy);
|
QCOMPARE(socket.proxy().type(), QNetworkProxy::DefaultProxy);
|
||||||
QCOMPARE(socket.readBufferSize(), qint64(0));
|
QCOMPARE(socket.readBufferSize(), qint64(0));
|
||||||
QCOMPARE(socket.socketDescriptor(), -1);
|
QCOMPARE(socket.socketDescriptor(), (qintptr)-1);
|
||||||
QCOMPARE(socket.socketType(), QAbstractSocket::TcpSocket);
|
QCOMPARE(socket.socketType(), QAbstractSocket::TcpSocket);
|
||||||
QVERIFY(!socket.waitForConnected(10));
|
QVERIFY(!socket.waitForConnected(10));
|
||||||
QTest::ignoreMessage(QtWarningMsg, "QSslSocket::waitForDisconnected() is not allowed in UnconnectedState");
|
QTest::ignoreMessage(QtWarningMsg, "QSslSocket::waitForDisconnected() is not allowed in UnconnectedState");
|
||||||
|
Loading…
Reference in New Issue
Block a user