Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-65166

QUdpSocket::readDatagram no longer returns originating host (Windows only regression)

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Not Evaluated
    • Resolution: Duplicate
    • Affects Version/s: 5.9.3
    • Fix Version/s: None
    • Component/s: Network: Sockets
    • Labels:
      None
    • Environment:
      Windows 7, 64 bit

      Description

      This issue originates from inside of qnativesocketengine_win.cpp.

      A fix from 5.9.2 to 5.9.3 corrected a call to WSAIoctl to obtain the function address of WSARecvMsg inside of QNativeSocketEnginePrivate::createNewSocket, correctly passing the socket value instead of the previous value of socketDescriptor. Previously this would have not returned the pointer and left recvmsg set to null.

      The issue arises because the WSARecvMsg functions, at least as to how it is currently (now correctly) being used does NOT fill in the sender address return value, instead leaving it blank. The for-loop that sets cmsgptr = WSA_CMSG_FIRSTHDR(&msg) always sets cmsgptr to null, exiting the loop. (nativeReceiveDatagram)

      With the incorrect code from 5.9.2 in place, recgmsg is set to null and this code is never called; instead qt_socket_getPortAndAddress is used which does properly fill in the return address.

      The simple solution is to just never use the extended recvmsg/sendmsg functions and instead use the base WsaRecv/WSASend functions (leave the pointers as null or completely remove the code that uses them), which allows the previous functioning code to work.

      According to the MSDN does, the extended functions are only minimally supported on Windows 8 and Windows Vista, which may be part of the issue - they apparently do not work on all supported platforms (Windows 7 for example). The extended functions also do not seem to be giving any extra functionality, either by themselves or in the context where they are currently being used - at least none that is not already being provided by existing, more-compatible and functioning code.

        Attachments

          Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            Activity

              People

              • Assignee:
                tpochep Timur Pocheptsov
                Reporter:
                tcwilson tcwilson
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Gerrit Reviews

                  There are no open Gerrit changes