Fix bytesAvailable() on UDP under Windows
When ::WSAIoctl() reports 1 byte available for reading, we are trying to peek an incoming datagram to ensure that the data is actually delivered. But, according to MSDN docs, we are not allowed to pass NULL as 'lpNumberOfBytesRecvd' parameter to ::WSARecvFrom() call, if 'lpOverlapped' parameter is also NULL. The case with an empty datagram is fixed accordingly. Change-Id: Id13038245332d3fb4bc18038d44a7cfd7ce04775 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
7c2850cd8f
commit
6adff20fe6
|
|
@ -1090,11 +1090,14 @@ qint64 QNativeSocketEnginePrivate::nativeBytesAvailable() const
|
|||
WSABUF buf;
|
||||
buf.buf = &c;
|
||||
buf.len = sizeof(c);
|
||||
DWORD bytesReceived;
|
||||
DWORD flags = MSG_PEEK;
|
||||
if (::WSARecvFrom(socketDescriptor, &buf, 1, 0, &flags, 0,0,0,0) == SOCKET_ERROR) {
|
||||
if (::WSARecvFrom(socketDescriptor, &buf, 1, &bytesReceived, &flags, 0,0,0,0) == SOCKET_ERROR) {
|
||||
int err = WSAGetLastError();
|
||||
if (err != WSAECONNRESET && err != WSAENETRESET)
|
||||
return 0;
|
||||
} else {
|
||||
return bytesReceived;
|
||||
}
|
||||
}
|
||||
return nbytes;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ osx
|
|||
windows
|
||||
osx
|
||||
[asyncReadDatagram]
|
||||
windows
|
||||
osx
|
||||
[multicastLeaveAfterClose]
|
||||
osx
|
||||
|
|
|
|||
Loading…
Reference in New Issue