54 #if defined(QNATIVESOCKETENGINE_DEBUG) 61 #if defined(QNATIVESOCKETENGINE_DEBUG) 63 void verboseWSErrorDebug(
int r)
66 case WSANOTINITIALISED :
qDebug(
"WSA error : WSANOTINITIALISED");
break;
67 case WSAEINTR:
qDebug(
"WSA error : WSAEINTR");
break;
68 case WSAEBADF:
qDebug(
"WSA error : WSAEBADF");
break;
69 case WSAEACCES:
qDebug(
"WSA error : WSAEACCES");
break;
70 case WSAEFAULT:
qDebug(
"WSA error : WSAEFAULT");
break;
71 case WSAEINVAL:
qDebug(
"WSA error : WSAEINVAL");
break;
72 case WSAEMFILE:
qDebug(
"WSA error : WSAEMFILE");
break;
73 case WSAEWOULDBLOCK:
qDebug(
"WSA error : WSAEWOULDBLOCK");
break;
74 case WSAEINPROGRESS:
qDebug(
"WSA error : WSAEINPROGRESS");
break;
75 case WSAEALREADY:
qDebug(
"WSA error : WSAEALREADY");
break;
76 case WSAENOTSOCK:
qDebug(
"WSA error : WSAENOTSOCK");
break;
77 case WSAEDESTADDRREQ:
qDebug(
"WSA error : WSAEDESTADDRREQ");
break;
78 case WSAEMSGSIZE:
qDebug(
"WSA error : WSAEMSGSIZE");
break;
79 case WSAEPROTOTYPE:
qDebug(
"WSA error : WSAEPROTOTYPE");
break;
80 case WSAENOPROTOOPT:
qDebug(
"WSA error : WSAENOPROTOOPT");
break;
81 case WSAEPROTONOSUPPORT:
qDebug(
"WSA error : WSAEPROTONOSUPPORT");
break;
82 case WSAESOCKTNOSUPPORT:
qDebug(
"WSA error : WSAESOCKTNOSUPPORT");
break;
83 case WSAEOPNOTSUPP:
qDebug(
"WSA error : WSAEOPNOTSUPP");
break;
84 case WSAEPFNOSUPPORT:
qDebug(
"WSA error : WSAEPFNOSUPPORT");
break;
85 case WSAEAFNOSUPPORT:
qDebug(
"WSA error : WSAEAFNOSUPPORT");
break;
86 case WSAEADDRINUSE:
qDebug(
"WSA error : WSAEADDRINUSE");
break;
87 case WSAEADDRNOTAVAIL:
qDebug(
"WSA error : WSAEADDRNOTAVAIL");
break;
88 case WSAENETDOWN:
qDebug(
"WSA error : WSAENETDOWN");
break;
89 case WSAENETUNREACH:
qDebug(
"WSA error : WSAENETUNREACH");
break;
90 case WSAENETRESET:
qDebug(
"WSA error : WSAENETRESET");
break;
91 case WSAECONNABORTED:
qDebug(
"WSA error : WSAECONNABORTED");
break;
92 case WSAECONNRESET:
qDebug(
"WSA error : WSAECONNRESET");
break;
93 case WSAENOBUFS:
qDebug(
"WSA error : WSAENOBUFS");
break;
94 case WSAEISCONN:
qDebug(
"WSA error : WSAEISCONN");
break;
95 case WSAENOTCONN:
qDebug(
"WSA error : WSAENOTCONN");
break;
96 case WSAESHUTDOWN:
qDebug(
"WSA error : WSAESHUTDOWN");
break;
97 case WSAETOOMANYREFS:
qDebug(
"WSA error : WSAETOOMANYREFS");
break;
98 case WSAETIMEDOUT:
qDebug(
"WSA error : WSAETIMEDOUT");
break;
99 case WSAECONNREFUSED:
qDebug(
"WSA error : WSAECONNREFUSED");
break;
100 case WSAELOOP:
qDebug(
"WSA error : WSAELOOP");
break;
101 case WSAENAMETOOLONG:
qDebug(
"WSA error : WSAENAMETOOLONG");
break;
102 case WSAEHOSTDOWN:
qDebug(
"WSA error : WSAEHOSTDOWN");
break;
103 case WSAEHOSTUNREACH:
qDebug(
"WSA error : WSAEHOSTUNREACH");
break;
104 case WSAENOTEMPTY:
qDebug(
"WSA error : WSAENOTEMPTY");
break;
105 case WSAEPROCLIM:
qDebug(
"WSA error : WSAEPROCLIM");
break;
106 case WSAEUSERS:
qDebug(
"WSA error : WSAEUSERS");
break;
107 case WSAEDQUOT:
qDebug(
"WSA error : WSAEDQUOT");
break;
108 case WSAESTALE:
qDebug(
"WSA error : WSAESTALE");
break;
109 case WSAEREMOTE:
qDebug(
"WSA error : WSAEREMOTE");
break;
110 case WSAEDISCON:
qDebug(
"WSA error : WSAEDISCON");
break;
111 default:
qDebug(
"WSA error : Unknown");
break;
120 static QByteArray qt_prettyDebug(
const char *
data,
int len,
int maxLength)
122 if (!data)
return "(null)";
124 for (
int i = 0; i < len; ++i) {
126 if (isprint(
int(
uchar(c)))) {
129 case '\n': out +=
"\\n";
break;
130 case '\r': out +=
"\\r";
break;
131 case '\t': out +=
"\\t";
break;
146 #define WS_ERROR_DEBUG(x) verboseWSErrorDebug(x); 150 #define WS_ERROR_DEBUG(x) Q_UNUSED(x) 158 #ifndef SO_EXCLUSIVEADDRUSE 159 #define SO_EXCLUSIVEADDRUSE ((int)(~SO_REUSEADDR)) 163 #define QT_SOCKLEN_T int 164 #define QT_SOCKOPTLEN_T int 173 #if !defined (QT_NO_IPV6) 177 for (
int i = 0; i < 16; ++i)
186 WSANtohs(socketDescriptor, sa6->
sin6_port, port);
189 if (sa->
a.sa_family == AF_INET) {
190 const sockaddr_in *sa4 = &sa->
a4;
192 WSANtohl(socketDescriptor, sa4->sin_addr.s_addr, &addr);
198 WSANtohs(socketDescriptor, sa4->sin_port, port);
213 #if !defined(QT_NO_IPV6) 218 WSAHtons(socketDescriptor, port, &(sockAddrIPv6->
sin6_port));
222 *sockAddrPtr = (
struct sockaddr *) sockAddrIPv6;
227 memset(sockAddrIPv4, 0,
sizeof(sockaddr_in));
228 sockAddrIPv4->sin_family = AF_INET;
229 WSAHtons(socketDescriptor, port, &(sockAddrIPv4->sin_port));
230 WSAHtonl(socketDescriptor, address.
toIPv4Address(), &(sockAddrIPv4->sin_addr.s_addr));
231 *sockAddrSize =
sizeof(sockaddr_in);
232 *sockAddrPtr = (
struct sockaddr *) sockAddrIPv4;
245 if (::getsockopt(socketDescriptor, SOL_SOCKET, SO_TYPE, (
char *) &value, &valueSize) != 0) {
248 if (value == SOCK_STREAM)
250 else if (value == SOCK_DGRAM)
263 if (::getsockopt(socketDescriptor, SOL_SOCKET, SO_MAX_MSG_SIZE, (
char *) &value, &valueSize) != 0) {
276 if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0) {
277 qWarning(
"QTcpSocketAPI: WinSock v2.0 initialization failed.");
293 #ifndef SIO_UDP_CONNRESET 295 # define IOC_VENDOR 0x18000000 298 # define _WSAIOW(x,y) (IOC_IN|(x)|(y)) 300 # define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12) 318 SOCKET socket = ::WSASocket(protocol, type, 0, NULL, 0, WSA_FLAG_OVERLAPPED);
320 if (socket == INVALID_SOCKET) {
321 int err = WSAGetLastError();
324 case WSANOTINITIALISED:
327 case WSAEAFNOSUPPORT:
328 case WSAESOCKTNOSUPPORT:
344 #if !defined(Q_OS_WINCE) 348 DWORD dwBytesReturned = 0;
349 int bNewBehavior = 1;
351 NULL, 0, &dwBytesReturned, NULL, NULL) == SOCKET_ERROR) {
353 int err = WSAGetLastError();
359 socketDescriptor = socket;
378 int level = SOL_SOCKET;
391 unsigned long buf = 0;
392 if (WSAIoctl(socketDescriptor, FIONBIO, 0,0, &buf,
sizeof(buf), 0,0,0) == 0)
417 level = IPPROTO_IPV6;
418 n = IPV6_MULTICAST_HOPS;
423 n = IP_MULTICAST_TTL;
429 level = IPPROTO_IPV6;
430 n = IPV6_MULTICAST_LOOP;
435 n = IP_MULTICAST_LOOP;
440 #if Q_BYTE_ORDER != Q_LITTLE_ENDIAN 441 #error code assumes windows is little endian 445 if (getsockopt(socketDescriptor, level, n, (
char *) &v, &len) == 0)
465 int level = SOL_SOCKET;
479 unsigned long buf = v;
480 unsigned long outBuf;
481 DWORD sizeWritten = 0;
482 if (::WSAIoctl(socketDescriptor, FIONBIO, &buf,
sizeof(
unsigned long), &outBuf,
sizeof(
unsigned long), &sizeWritten, 0,0) == SOCKET_ERROR) {
508 level = IPPROTO_IPV6;
509 n = IPV6_MULTICAST_HOPS;
514 n = IP_MULTICAST_TTL;
520 level = IPPROTO_IPV6;
521 n = IPV6_MULTICAST_LOOP;
526 n = IP_MULTICAST_LOOP;
531 if (::setsockopt(socketDescriptor, level, n, (
char*)&v,
sizeof(v)) != 0) {
545 localAddress.clear();
549 if (socketDescriptor == -1)
556 memset(&sa, 0,
sizeof(sa));
557 if (::getsockname(socketDescriptor, &sa.
a, &sockAddrSize) == 0) {
560 switch (sa.
a.sa_family) {
564 #if !defined (QT_NO_IPV6) 574 int err = WSAGetLastError();
576 if (err == WSAENOTSOCK) {
578 InvalidSocketErrorString);
583 memset(&sa, 0,
sizeof(sa));
584 if (::getpeername(socketDescriptor, &sa.
a, &sockAddrSize) == 0) {
592 #if defined (QNATIVESOCKETENGINE_DEBUG) 593 QString socketProtocolStr =
"UnknownProtocol";
597 QString socketTypeStr =
"UnknownSocketType";
601 qDebug(
"QNativeSocketEnginePrivate::fetchConnectionParameters() localAddress == %s, localPort = %i, peerAddress == %s, peerPort = %i, socketProtocol == %s, socketType == %s", localAddress.toString().toLatin1().constData(), localPort, peerAddress.toString().toLatin1().constData(), peerPort, socketProtocolStr.
toLatin1().
constData(), socketTypeStr.
toLatin1().
constData());
611 #if defined (QNATIVESOCKETENGINE_DEBUG) 615 struct sockaddr_in sockAddrIPv4;
617 struct sockaddr *sockAddrPtr = 0;
623 int connectResult = ::WSAConnect(socketDescriptor, sockAddrPtr, sockAddrSize, 0,0,0,0);
624 if (connectResult == SOCKET_ERROR) {
625 int err = WSAGetLastError();
629 case WSANOTINITIALISED:
635 case WSAEWOULDBLOCK: {
643 if (::getsockopt(socketDescriptor, SOL_SOCKET, SO_ERROR, (
char *) &value, &valueSize) == 0) {
644 if (value == WSAECONNREFUSED) {
649 if (value == WSAETIMEDOUT) {
654 if (value == WSAEHOSTUNREACH) {
659 if (value == WSAEADDRNOTAVAIL) {
674 case WSAECONNREFUSED:
685 case WSAEHOSTUNREACH:
701 #if defined (QNATIVESOCKETENGINE_DEBUG) 702 qDebug(
"QNativeSocketEnginePrivate::nativeConnect(%s, %i) == false (%s)",
705 ?
"Connection in progress" : socketErrorString.toLatin1().constData());
713 #if defined (QNATIVESOCKETENGINE_DEBUG) 714 qDebug(
"QNativeSocketEnginePrivate::nativeConnect(%s, %i) == true",
743 struct sockaddr_in sockAddrIPv4;
745 struct sockaddr *sockAddrPtr = 0;
751 int bindResult = ::bind(socketDescriptor, sockAddrPtr, sockAddrSize);
752 if (bindResult == SOCKET_ERROR) {
753 int err = WSAGetLastError();
756 case WSANOTINITIALISED:
766 case WSAEADDRNOTAVAIL:
773 #if defined (QNATIVESOCKETENGINE_DEBUG) 774 qDebug(
"QNativeSocketEnginePrivate::nativeBind(%s, %i) == false (%s)",
781 #if defined (QNATIVESOCKETENGINE_DEBUG) 782 qDebug(
"QNativeSocketEnginePrivate::nativeBind(%s, %i) == true",
792 if (::listen(socketDescriptor, backlog) == SOCKET_ERROR) {
793 int err = WSAGetLastError();
796 case WSANOTINITIALISED:
801 PortInuseErrorString);
807 #if defined (QNATIVESOCKETENGINE_DEBUG) 808 qDebug(
"QNativeSocketEnginePrivate::nativeListen(%i) == false (%s)",
809 backlog, socketErrorString.toLatin1().constData());
814 #if defined (QNATIVESOCKETENGINE_DEBUG) 815 qDebug(
"QNativeSocketEnginePrivate::nativeListen(%i) == true", backlog);
824 int acceptedDescriptor = WSAAccept(socketDescriptor, 0,0,0,0);
834 #if defined (QNATIVESOCKETENGINE_DEBUG) 835 qDebug(
"QNativeSocketEnginePrivate::nativeAccept() == %i", acceptedDescriptor);
837 return acceptedDescriptor;
851 struct ip_mreq mreq4;
853 struct ipv6_mreq mreq6;
856 level = IPPROTO_IPV6;
858 sockArg =
reinterpret_cast<char *
>(&mreq6);
859 sockArgSize =
sizeof(mreq6);
860 memset(&mreq6, 0,
sizeof(mreq6));
862 memcpy(&mreq6.ipv6mr_multiaddr, &ip6,
sizeof(ip6));
863 mreq6.ipv6mr_interface = iface.
index();
869 sockArg =
reinterpret_cast<char *
>(&mreq4);
870 sockArgSize =
sizeof(mreq4);
871 memset(&mreq4, 0,
sizeof(mreq4));
872 mreq4.imr_multiaddr.s_addr = htonl(groupAddress.
toIPv4Address());
876 if (!addressEntries.
isEmpty()) {
885 mreq4.imr_interface.s_addr = INADDR_ANY;
894 int res = setsockopt(d->
socketDescriptor, level, sockOpt, sockArg, sockArgSize);
937 if (::getsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, (
char *) &v, &sizeofv) == -1)
946 if (::getsockopt(socketDescriptor, IPPROTO_IP, IP_MULTICAST_IF, (
char *) &v, &sizeofv) == -1)
951 for (
int i = 0; i < ifaces.
count(); ++i) {
956 for (
int j = 0; j < entries.
count(); ++j) {
958 if (entry.
ip() == ipv4)
971 return (::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, (
char *) &v,
sizeof(v)) != -1);
978 for (
int i = 0; i < entries.
count(); ++i) {
983 int r = ::setsockopt(socketDescriptor, IPPROTO_IP, IP_MULTICAST_IF, (
char *) &v,
sizeof(v));
991 v.s_addr = INADDR_ANY;
992 return (::setsockopt(socketDescriptor, IPPROTO_IP, IP_MULTICAST_IF, (
char *) &v,
sizeof(v)) != -1);
997 unsigned long nbytes = 0;
998 unsigned long dummy = 0;
999 DWORD sizeWritten = 0;
1000 if (::WSAIoctl(socketDescriptor, FIONREAD, &dummy,
sizeof(dummy), &nbytes,
sizeof(nbytes), &sizeWritten, 0,0) == SOCKET_ERROR) {
1014 buf.len =
sizeof(
c);
1015 DWORD flags = MSG_PEEK;
1016 if (::WSARecvFrom(socketDescriptor, &buf, 1, 0, &flags, 0,0,0,0) == SOCKET_ERROR)
1025 #if !defined(Q_OS_WINCE) 1029 memset(&storage, 0, storageSize);
1031 bool result =
false;
1038 buf.len =
sizeof(
c);
1039 DWORD available = 0;
1040 DWORD flags = MSG_PEEK;
1041 int ret = ::WSARecvFrom(socketDescriptor, &buf, 1, &available, &flags, &storage.
a, &storageSize,0,0);
1042 int err = WSAGetLastError();
1043 if (ret == SOCKET_ERROR && err != WSAEMSGSIZE) {
1045 if (err == WSAECONNRESET) {
1050 ::WSARecvFrom(socketDescriptor, &buf, 1, &available, &flags,
1051 &storage.
a, &storageSize, 0, 0);
1060 bool result =
false;
1063 FD_SET((SOCKET)socketDescriptor, &readS);
1066 timeout.tv_usec = 5000;
1067 int available =
::select(1, &readS, 0, 0, &timeout);
1068 result = available > 0 ? true :
false;
1071 #if defined (QNATIVESOCKETENGINE_DEBUG) 1072 qDebug(
"QNativeSocketEnginePrivate::nativeHasPendingDatagrams() == %s",
1073 result ?
"true" :
"false");
1082 #if !defined(Q_OS_WINCE) 1085 DWORD bufferCount = 5;
1091 static char udpMessagePeekBuffer[8192];
1093 buf =
new WSABUF[bufferCount];
1094 for (DWORD i=0; i<bufferCount; i++) {
1095 buf[i].buf = udpMessagePeekBuffer;
1096 buf[i].len =
sizeof(udpMessagePeekBuffer);
1099 DWORD bytesRead = 0;
1100 recvResult = ::WSARecv(socketDescriptor, buf, bufferCount, &bytesRead, &flags, 0,0);
1101 int err = WSAGetLastError();
1102 if (recvResult != SOCKET_ERROR) {
1105 }
else if (recvResult == SOCKET_ERROR && err == WSAEMSGSIZE) {
1108 }
else if (recvResult == SOCKET_ERROR) {
1120 DWORD bytesReturned;
1121 int ioResult = WSAIoctl(socketDescriptor, FIONREAD, 0,0, &size,
sizeof(size), &bytesReturned, 0, 0);
1122 if (ioResult == SOCKET_ERROR) {
1123 int err = WSAGetLastError();
1130 #if defined (QNATIVESOCKETENGINE_DEBUG) 1131 qDebug(
"QNativeSocketEnginePrivate::nativePendingDatagramSize() == %li", ret);
1144 memset(&aa, 0,
sizeof(aa));
1150 buf.len = maxLength;
1151 #if !defined(Q_OS_WINCE) 1153 buf.len = maxLength;
1156 buf.buf = data ?
data : &tmpChar;
1157 buf.len = maxLength;
1161 DWORD bytesRead = 0;
1162 int wsaRet = ::WSARecvFrom(socketDescriptor, &buf, 1, &bytesRead, &flags, &aa.
a, &sz,0,0);
1163 if (wsaRet == SOCKET_ERROR) {
1164 int err = WSAGetLastError();
1165 if (err == WSAEMSGSIZE) {
1168 ret =
qint64(bytesRead) > maxLength ? maxLength :
qint64(bytesRead);
1180 #if defined (QNATIVESOCKETENGINE_DEBUG) 1181 qDebug(
"QNativeSocketEnginePrivate::nativeReceiveDatagram(%p \"%s\", %li, %s, %i) == %li",
1182 data, qt_prettyDebug(data, qMin<qint64>(ret, 16), ret).
data(), maxLength,
1184 port ? *port : 0, ret);
1195 struct sockaddr_in sockAddrIPv4;
1197 struct sockaddr *sockAddrPtr = 0;
1203 #if !defined(Q_OS_WINCE) 1204 buf.buf = len ? (
char*)data : 0;
1207 buf.buf = len ? (
char*)data : &tmp;
1211 DWORD bytesSent = 0;
1212 if (::WSASendTo(socketDescriptor, &buf, 1, &bytesSent, flags, sockAddrPtr, sockAddrSize, 0,0) == SOCKET_ERROR) {
1213 int err = WSAGetLastError();
1228 #if defined (QNATIVESOCKETENGINE_DEBUG) 1229 qDebug(
"QNativeSocketEnginePrivate::nativeSendDatagram(%p \"%s\", %li, \"%s\", %i) == %li", data,
1242 qint64 bytesToSend = len;
1246 buf.buf = (
char*)data + ret;
1247 buf.len = bytesToSend;
1249 DWORD bytesWritten = 0;
1251 int socketRet = ::WSASend(socketDescriptor, &buf, 1, &bytesWritten, flags, 0,0);
1253 ret +=
qint64(bytesWritten);
1256 if (socketRet != SOCKET_ERROR) {
1261 }
else if ((err = WSAGetLastError()) == WSAEWOULDBLOCK) {
1263 }
else if (err == WSAENOBUFS) {
1273 case WSAECONNABORTED:
1285 bytesToSend = qMin<qint64>(49152, len - ret);
1288 #if defined (QNATIVESOCKETENGINE_DEBUG) 1289 qDebug(
"QNativeSocketEnginePrivate::nativeWrite(%p \"%s\", %li) == %li",
1290 data, qt_prettyDebug(data,
qMin((
int)ret, 16), (
int)ret).
data(), (
int)len, (
int)ret);
1301 buf.len = maxLength;
1303 DWORD bytesRead = 0;
1304 #if defined(Q_OS_WINCE) 1307 if (::WSARecv(socketDescriptor, &buf, 1, &bytesRead, &flags, 0,0) == SOCKET_ERROR) {
1308 int err = WSAGetLastError();
1311 case WSAEWOULDBLOCK:
1319 case WSAECONNABORTED:
1327 if (WSAGetLastError() == WSAEWOULDBLOCK)
1333 #if defined (QNATIVESOCKETENGINE_DEBUG) 1335 qDebug(
"QNativeSocketEnginePrivate::nativeRead(%p \"%s\", %l) == %li",
1336 data, qt_prettyDebug(data,
qMin((
int)bytesRead, 16), (
int)bytesRead).
data(), (
int)maxLength, (
int)ret);
1338 qDebug(
"QNativeSocketEnginePrivate::nativeRead(%p, %l) == -2 (WOULD BLOCK)",
1339 data,
int(maxLength));
1348 bool readEnabled = selectForRead && readNotifier && readNotifier->isEnabled();
1350 readNotifier->setEnabled(
false);
1356 memset(&fds, 0,
sizeof(fd_set));
1358 fds.fd_array[0] = (SOCKET)socketDescriptor;
1361 tv.tv_sec = timeout / 1000;
1362 tv.tv_usec = (timeout % 1000) * 1000;
1364 if (selectForRead) {
1365 ret =
select(0, &fds, 0, 0, timeout < 0 ? 0 : &tv);
1371 FD_ZERO(&fdexception);
1372 FD_SET((SOCKET)socketDescriptor, &fdexception);
1374 ret =
select(0, 0, &fds, &fdexception, timeout < 0 ? 0 : &tv);
1377 if (ret > 0 && FD_ISSET((SOCKET)socketDescriptor, &fdexception))
1382 readNotifier->setEnabled(
true);
1388 bool checkRead,
bool checkWrite,
1389 bool *selectForRead,
bool *selectForWrite)
const 1391 bool readEnabled = checkRead && readNotifier && readNotifier->isEnabled();
1393 readNotifier->setEnabled(
false);
1401 memset(&fdread, 0,
sizeof(fd_set));
1403 fdread.fd_count = 1;
1404 fdread.fd_array[0] = (SOCKET)socketDescriptor;
1406 memset(&fdwrite, 0,
sizeof(fd_set));
1407 FD_ZERO(&fdexception);
1409 fdwrite.fd_count = 1;
1410 fdwrite.fd_array[0] = (SOCKET)socketDescriptor;
1413 FD_SET((SOCKET)socketDescriptor, &fdexception);
1417 tv.tv_sec = timeout / 1000;
1418 tv.tv_usec = (timeout % 1000) * 1000;
1420 #if !defined(Q_OS_WINCE) 1421 ret =
select(socketDescriptor + 1, &fdread, &fdwrite, &fdexception, timeout < 0 ? 0 : &tv);
1423 ret =
select(1, &fdread, &fdwrite, &fdexception, timeout < 0 ? 0 : &tv);
1427 if (ret > 0 && FD_ISSET((SOCKET)socketDescriptor, &fdexception))
1431 readNotifier->setEnabled(
true);
1436 *selectForRead = FD_ISSET((SOCKET)socketDescriptor, &fdread);
1437 *selectForWrite = FD_ISSET((SOCKET)socketDescriptor, &fdwrite);
1444 #if defined (QTCPSOCKETENGINE_DEBUG) 1445 qDebug(
"QNativeSocketEnginePrivate::nativeClose()");
1451 ::closesocket(socketDescriptor);
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setScopeId(const QString &id)
Sets the IPv6 scope ID of the address to id.
QString scopeId() const
Returns the scope ID of an IPv6 address.
qint64 nativeBytesAvailable() const
static QAbstractSocket::SocketType qt_socket_getType(int socketDescriptor)
int option(QNativeSocketEngine::SocketOption option) const
Returns the value of the socket option opt.
QString & sprintf(const char *format,...)
Safely builds a formatted string from the format string cformat and an arbitrary list of arguments...
Q_IPV6ADDR toIPv6Address() const
Returns the IPv6 address as a Q_IPV6ADDR structure.
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
QHostAddress ip() const
This function returns one IPv4 or IPv6 address found, that was found in a network interface...
SocketType
This enum describes the transport layer protocol.
#define WS_ERROR_DEBUG(x)
int toInt(bool *ok=0, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
static QAbstractEventDispatcher * instance(QThread *thread=0)
Returns a pointer to the event dispatcher object for the specified thread.
The QByteArray class provides an array of bytes.
static void qt_socket_getPortAndAddress(SOCKET socketDescriptor, const qt_sockaddr *sa, quint16 *port, QHostAddress *address)
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *)
struct qt_in6_addr sin6_addr
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
quint32 toIPv4Address() const
Returns the IPv4 address as a number.
NetworkLayerProtocol
This enum describes the network layer protocol values used in Qt.
bool nativeHasPendingDatagrams() const
The QString class provides a Unicode character string.
bool nativeConnect(const QHostAddress &address, quint16 port)
bool setOption(QNativeSocketEngine::SocketOption option, int value)
Sets the socket option opt to v.
qint64 nativeReceiveDatagram(char *data, qint64 maxLength, QHostAddress *address, quint16 *port)
The QNativeSocketEngine class provides low level access to a socket.
bool nativeListen(int backlog)
qint64 nativePendingDatagramSize() const
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
Q_CORE_EXPORT void qDebug(const char *,...)
#define QT_BEGIN_NAMESPACE
This macro expands to.
static bool multicastMembershipHelper(QNativeSocketEnginePrivate *d, int how6, int how4, const QHostAddress &groupAddress, const QNetworkInterface &iface)
#define SO_EXCLUSIVEADDRUSE
const T & at(int i) const
Returns the item at index position i in the list.
bool isValid() const
Returns true if this QNetworkInterface object contains valid information about a network interface...
Q_CORE_EXPORT void qWarning(const char *,...)
bool nativeJoinMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &iface)
static const char * data(const QByteArray &arr)
QString toString() const
Returns the address as a string.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
static void qt_socket_setPortAndAddress(SOCKET socketDescriptor, sockaddr_in *sockAddrIPv4, qt_sockaddr_in6 *sockAddrIPv6, quint16 port, const QHostAddress &address, sockaddr **sockAddrPtr, QT_SOCKLEN_T *sockAddrSize)
Sets the port and address to a sockaddr.
int nativeSelect(int timeout, bool selectForRead) const
static QNetworkInterface interfaceFromIndex(int index)
Returns a QNetworkInterface object for the interface whose internal ID is index.
T & first()
Returns a reference to the first item in the list.
const char * constData() const
Returns a pointer to the data stored in the byte array.
static const MacSpecialKey entries[NumEntries]
bool fetchConnectionParameters()
Fetches information about both ends of the connection: whatever is available.
qint64 nativeWrite(const char *data, qint64 length)
QAbstractSocket::NetworkLayerProtocol protocol() const
Returns the network layer protocol of the host address.
void setAddress(quint32 ip4Addr)
Set the IPv4 address specified by ip4Addr.
static QList< QNetworkInterface > allInterfaces()
Returns a listing of all the network interfaces found on the host machine.
void setError(QAbstractSocket::SocketError error, ErrorString errorString) const
Sets the error and error string if not set already.
void setEnabled(bool)
If enable is true, the notifier is enabled; otherwise the notifier is disabled.
bool nativeBind(const QHostAddress &address, quint16 port)
if(void) toggleToolbarShown
int index() const
Returns the interface system index, if known.
InterfaceFlags flags() const
Returns the flags associated with this network interface.
QNetworkInterface nativeMulticastInterface() const
bool nativeSetMulticastInterface(const QNetworkInterface &iface)
The QNetworkInterface class provides a listing of the host's IP addresses and network interfaces...
The QHostAddress class provides an IP address.
static int qt_socket_getMaxMsgSize(int socketDescriptor)
bool nativeLeaveMulticastGroup(const QHostAddress &groupAddress, const QNetworkInterface &iface)
#define SIO_UDP_CONNRESET
QList< QNetworkAddressEntry > addressEntries() const
Returns the list of IP addresses that this interface possesses along with their associated netmasks a...
The QNetworkAddressEntry class stores one IP address supported by a network interface, along with its associated netmask and broadcast address.
qint64 nativeSendDatagram(const char *data, qint64 length, const QHostAddress &host, quint16 port)
bool createNewSocket(QAbstractSocket::SocketType type, QAbstractSocket::NetworkLayerProtocol protocol)
Creates and returns a new socket descriptor of type socketType and socketProtocol.
qint64 nativeRead(char *data, qint64 maxLength)
void qErrnoWarning(const char *msg,...)
#define forever
This macro is provided for convenience for writing infinite loops.