summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qnativesocketengine_p.h
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2011-06-07 14:38:38 +0100
committerQt by Nokia <qt-info@nokia.com>2011-06-22 11:01:00 +0200
commit85136496bc8517951dcc3e670d1a46d340819f0d (patch)
tree86ca9423d926ed2f85744f4159966549f454e8f8 /src/network/socket/qnativesocketengine_p.h
parent665d8a045455214d2cfca72076da6bc75d3058c7 (diff)
IPv4 + IPv6 dual stack sockets
Adds support for binding "dual stack" sockets (via QUdpSocket or QTcpServer). A dual stack socket will accept incoming connections on either IPv4 or IPv6 interfaces. QHostAddress::Any - use this to bind a dual stack socket QHostAddress::AnyIPv6 - use this to bind a socket for IPv6 only QHostAddress::AnyIPv4 - use this to bind a socket for IPv4 only Binding to a specific address rather than one of the "any" addresses is restricting you to a protocol anyway so no behaviour change there. IPv6 sockets were previously dual stack on some OS and v6 only on others Any previously meant IPv4 only This commit implemented & tested on Windows 7, Linux (Ubuntu 10.04) and Mac OS 10.6.7. Windows XP and server 2003 do not support dual stack sockets, even though they can support IPv6. On those versions, QHostAddress::Any will still bind to IPv4 0.0.0.0 (which is also the behaviour anywhere QT_NO_IPV6 is defined) Autotests run: qudpsocket (includes a new test case) qtcpserver (includes a new test case) qtcpsocket qnetworkreply qhostaddress Task-number: QTBUG-17080 Change-Id: Id486677c4f832e18dc0ff1a86c5f5fc422c9eb4f Reviewed-on: http://codereview.qt.nokia.com/421 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Thiago Macieira <thiago.macieira@nokia.com> Reviewed-by: Markus Goetz
Diffstat (limited to 'src/network/socket/qnativesocketengine_p.h')
-rw-r--r--src/network/socket/qnativesocketengine_p.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h
index c5c4b325d0..a024cd42d1 100644
--- a/src/network/socket/qnativesocketengine_p.h
+++ b/src/network/socket/qnativesocketengine_p.h
@@ -74,6 +74,11 @@ struct qt_sockaddr_storage {
char __ss_pad2[QT_SS_PAD2SIZE];
};
+#ifdef Q_OS_WIN
+#define QT_SOCKLEN_T int
+#define QT_SOCKOPTLEN_T int
+#endif
+
// sockaddr_in6 size changed between old and new SDK
// Only the new version is the correct one, so always
// use this structure.
@@ -265,6 +270,10 @@ public:
int nativeSelect(int timeout, bool selectForRead) const;
int nativeSelect(int timeout, bool checkRead, bool checkWrite,
bool *selectForRead, bool *selectForWrite) const;
+#ifdef Q_OS_WIN
+ void setPortAndAddress(sockaddr_in * sockAddrIPv4, qt_sockaddr_in6 * sockAddrIPv6,
+ quint16 port, const QHostAddress & address, sockaddr ** sockAddrPtr, QT_SOCKLEN_T *sockAddrSize);
+#endif
void nativeClose();