Changeset 769 for trunk/src/network/socket
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/network/socket/qabstractsocket.cpp
r651 r769 156 156 examples for an overview of both approaches. 157 157 158 159 160 158 161 QAbstractSocket can be used with QTextStream and QDataStream's 159 162 stream operators (operator<<() and operator>>()). There is one … … 170 173 the host lookup has succeeded. 171 174 175 176 177 178 172 179 \sa connected() 173 180 */ … … 178 185 This signal is emitted after connectToHost() has been called and 179 186 a connection has been successfully established. 187 188 189 190 180 191 181 192 \sa connectToHost(), disconnected() … … 352 363 #include "qabstractsocket_p.h" 353 364 365 366 354 367 #include <qabstracteventdispatcher.h> 355 368 #include <qdatetime.h> … … 1367 1380 #endif 1368 1381 } else { 1369 if (d->threadData->eventDispatcher) 1370 d->hostLookupId = QHostInfo::lookupHost(hostName, this, SLOT(_q_startConnecting(QHostInfo))); 1382 if (d->threadData->eventDispatcher) { 1383 // this internal API for QHostInfo either immediatly gives us the desired 1384 // QHostInfo from cache or later calls the _q_startConnecting slot. 1385 bool immediateResultValid = false; 1386 QHostInfo hostInfo = qt_qhostinfo_lookup(hostName, 1387 this, 1388 SLOT(_q_startConnecting(QHostInfo)), 1389 &immediateResultValid, 1390 &d->hostLookupId); 1391 if (immediateResultValid) { 1392 d->hostLookupId = -1; 1393 d->_q_startConnecting(hostInfo); 1394 } 1395 } 1371 1396 } 1372 1397 … … 1683 1708 If msecs is -1, this function will not time out. 1684 1709 1685 Note:This function may wait slightly longer than \a msecs,1710 This function may wait slightly longer than \a msecs, 1686 1711 depending on the time it takes to complete the host lookup. 1712 1713 1714 1687 1715 1688 1716 \sa connectToHost(), connected() … … 1723 1751 } 1724 1752 if (state() == UnconnectedState) 1725 return false; 1753 return false; 1726 1754 1727 1755 bool timedOut = true; … … 2355 2383 qDebug("QAbstractSocket::disconnectFromHost() aborting immediately"); 2356 2384 #endif 2385 2386 2387 2388 2357 2389 } else { 2358 2390 // Perhaps emit closing() -
trunk/src/network/socket/qlocalserver.cpp
r755 r769 123 123 d->pendingConnections.clear(); 124 124 d->closeServer(); 125 d->serverName = QString();126 d->fullServerName = QString();127 d->errorString = QString();125 d->serverName(); 126 d->fullServerName(); 127 d->errorString(); 128 128 d->error = QAbstractSocket::UnknownSocketError; 129 129 } … … 229 229 230 230 if (!d->listen(name)) { 231 d->serverName = QString();232 d->fullServerName = QString();231 d->serverName(); 232 d->fullServerName(); 233 233 return false; 234 234 } -
trunk/src/network/socket/qlocalserver_win.cpp
r651 r769 168 168 } else { 169 169 if (GetLastError() != ERROR_IO_INCOMPLETE) { 170 170 171 setError(QLatin1String("QLocalServerPrivate::_q_onNewConnection")); 171 closeServer();172 172 return; 173 173 } -
trunk/src/network/socket/qlocalsocket_p.h
r651 r769 129 129 void _q_error(QAbstractSocket::SocketError newError); 130 130 #elif defined(Q_OS_WIN) 131 ~QLocalSocketPrivate() { 132 CloseHandle(overlapped.hEvent); 133 } 134 131 ~QLocalSocketPrivate(); 132 void destroyPipeHandles(); 135 133 void setErrorString(const QString &function); 136 134 void _q_notified(); -
trunk/src/network/socket/qlocalsocket_tcp.cpp
r651 r769 103 103 case QAbstractSocket::UnconnectedState: 104 104 state = QLocalSocket::UnconnectedState; 105 serverName = QString();106 fullServerName = QString();105 serverName(); 106 fullServerName(); 107 107 break; 108 108 case QAbstractSocket::ConnectingState: … … 219 219 return; 220 220 221 d->errorString = QString();221 d->errorString(); 222 222 d->state = ConnectingState; 223 223 emit stateChanged(d->state); … … 334 334 Q_D(QLocalSocket); 335 335 d->tcpSocket->close(); 336 d->serverName = QString();337 d->fullServerName = QString();336 d->serverName(); 337 d->fullServerName(); 338 338 QIODevice::close(); 339 339 } -
trunk/src/network/socket/qlocalsocket_unix.cpp
r651 r769 110 110 case QAbstractSocket::UnconnectedState: 111 111 state = QLocalSocket::UnconnectedState; 112 serverName = QString();113 fullServerName = QString();112 serverName(); 113 fullServerName(); 114 114 break; 115 115 case QAbstractSocket::ConnectingState: … … 226 226 return; 227 227 228 d->errorString = QString();228 d->errorString(); 229 229 d->unixSocket.setSocketState(QAbstractSocket::ConnectingState); 230 230 d->state = ConnectingState; … … 342 342 } 343 343 connectingSocket = -1; 344 connectingName = QString();344 connectingName(); 345 345 connectingOpenMode = 0; 346 346 } … … 439 439 ::close(d->connectingSocket); 440 440 d->connectingSocket = -1; 441 d->connectingName = QString();441 d->connectingName(); 442 442 d->connectingOpenMode = 0; 443 d->serverName = QString();444 d->fullServerName = QString();443 d->serverName(); 444 d->fullServerName(); 445 445 QIODevice::close(); 446 446 } -
trunk/src/network/socket/qlocalsocket_win.cpp
r651 r769 40 40 ****************************************************************************/ 41 41 42 #include "qlocalsocket.h"43 42 #include "qlocalsocket_p.h" 44 43 … … 109 108 state(QLocalSocket::UnconnectedState) 110 109 { 110 111 112 113 114 115 116 117 118 119 120 121 122 123 111 124 } 112 125 … … 389 402 d->pendingReadyRead = false; 390 403 d->pipeClosed = false; 391 DisconnectNamedPipe(d->handle); 392 CloseHandle(d->handle); 404 d->destroyPipeHandles(); 393 405 d->handle = INVALID_HANDLE_VALUE; 394 406 ResetEvent(d->overlapped.hEvent); … … 413 425 { 414 426 Q_D(QLocalSocket); 427 428 429 430 431 432 433 434 435 415 436 flush(); 416 437 if (d->pipeWriter && d->pipeWriter->bytesToWrite() != 0) { … … 525 546 { 526 547 Q_D(const QLocalSocket); 527 return (d->handle != INVALID_HANDLE_VALUE); 548 if (d->handle == INVALID_HANDLE_VALUE) 549 return false; 550 551 return PeekNamedPipe(d->handle, NULL, 0, NULL, NULL, NULL); 528 552 } 529 553 -
trunk/src/network/socket/qnativesocketengine.cpp
r651 r769 780 780 return -1; 781 781 } else if (readBytes == -1) { 782 d->setError(QAbstractSocket::NetworkError, 783 QNativeSocketEnginePrivate::ReadErrorString); 782 if (!d->hasSetSocketError) { 783 d->hasSetSocketError = true; 784 d->socketError = QAbstractSocket::NetworkError; 785 d->socketErrorString = qt_error_string(); 786 } 784 787 close(); 785 788 return -1; -
trunk/src/network/socket/qnativesocketengine_unix.cpp
r651 r769 602 602 // well be 0, so we can't check recvfrom's return value. 603 603 ssize_t readBytes; 604 605 606 607 604 608 do { 605 609 char c; 606 610 readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize); 607 611 } while (readBytes == -1 && errno == EINTR); 612 608 613 609 614 // If there's no error, or if our buffer was too small, there must be a … … 662 667 663 668 ssize_t recvFromResult = 0; 669 670 671 672 673 664 674 do { 665 675 char c; … … 667 677 0, &aa.a, &sz); 668 678 } while (recvFromResult == -1 && errno == EINTR); 679 669 680 670 681 if (recvFromResult == -1) { … … 833 844 qt_ignore_sigpipe(); 834 845 835 // loop while ::write() returns -1 and errno == EINTR, in case836 // of an interrupting signal.837 846 ssize_t writtenBytes; 838 do { 839 #ifdef Q_OS_SYMBIAN 840 writtenBytes = ::write(socketDescriptor, data, len); 841 #else 842 writtenBytes = qt_safe_write(socketDescriptor, data, len); 843 #endif 844 // writtenBytes = QT_WRITE(socketDescriptor, data, len); ### TODO S60: Should this line be removed or the one above it? 845 } while (writtenBytes < 0 && errno == EINTR); 847 #ifdef Q_OS_SYMBIAN 848 // Symbian does not support signals natively and Open C returns EINTR when moving to offline 849 writtenBytes = ::write(socketDescriptor, data, len); 850 #else 851 writtenBytes = qt_safe_write(socketDescriptor, data, len); 852 #endif 846 853 847 854 if (writtenBytes < 0) { … … 883 890 884 891 ssize_t r = 0; 885 do { 886 #ifdef Q_OS_SYMBIAN 887 r = ::read(socketDescriptor, data, maxSize); 888 #else 889 r = qt_safe_read(socketDescriptor, data, maxSize); 890 #endif 891 } while (r == -1 && errno == EINTR); 892 #ifdef Q_OS_SYMBIAN 893 r = ::read(socketDescriptor, data, maxSize); 894 #else 895 r = qt_safe_read(socketDescriptor, data, maxSize); 896 #endif 892 897 893 898 if (r < 0) { … … 904 909 case EINVAL: 905 910 case EIO: 906 setError(QAbstractSocket::NetworkError, ReadErrorString);911 907 912 break; 908 913 #ifdef Q_OS_SYMBIAN -
trunk/src/network/socket/qnativesocketengine_win.cpp
r651 r769 1069 1069 case WSAEBADF: 1070 1070 case WSAEINVAL: 1071 setError(QAbstractSocket::NetworkError, ReadErrorString);1071 1072 1072 break; 1073 1073 case WSAECONNRESET: -
trunk/src/network/socket/qtcpserver.cpp
r651 r769 79 79 use waitForNewConnection(), which blocks until either a 80 80 connection is available or a timeout expires. 81 82 83 84 85 86 87 88 89 90 81 91 82 92 \sa QTcpSocket, {Fortune Server Example}, {Threaded Fortune Server Example}, … … 514 524 connections. 515 525 526 527 528 529 516 530 \sa hasPendingConnections() 517 531 */ … … 543 557 may not be usable with native socket functions, and should only be 544 558 used with QTcpSocket::setSocketDescriptor(). 559 560 561 562 563 545 564 546 565 \sa newConnection(), nextPendingConnection() -
trunk/src/network/socket/qtcpsocket.cpp
r651 r769 61 61 \bold{Note:} TCP sockets cannot be opened in QIODevice::Unbuffered mode. 62 62 63 64 65 66 67 68 69 70 71 72 63 73 \sa QTcpServer, QUdpSocket, QFtp, QNetworkAccessManager, 64 74 {Fortune Server Example}, {Fortune Client Example}, -
trunk/src/network/socket/qudpsocket.cpp
r651 r769 86 86 \l{network/broadcastreceiver}{Broadcast Receiver} examples 87 87 illustrate how to use QUdpSocket in applications. 88 89 90 91 92 93 94 95 96 97 88 98 89 99 \sa QTcpSocket
Note:
See TracChangeset
for help on using the changeset viewer.