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

QUdpSocket doesn't report ConnectionRefusedError on port unreachable error

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P4: Low
    • None
    • 5.13
    • Network: Sockets
    • None
    • Linux/X11, Windows

    Description

      If a program uses QUdpSocket to connectToHost(), and then write() some data, while the destination port is not being listened, it's expected to get ConnectionRefusedError (due to ICMP Destination Unreachable (Port Unreachable) message). It's what strace shows on the (failing) write() syscall: ECONNREFUSED. But in practice, the program doesn't get any error at all, because QNativeSocketEnginePrivate::nativeWrite() ignores ECONNREFUSED.

      In fact, the same happens on Windows, although there the native behavior is a bit different. Namely, when destination port is unreachable, and SIO_UDP_CONNRESET is enabled (which it is in QUdpSocket), a call to WSARecvFrom results in WSAECONNRESET. This should be checked by QUdpSocket and reported via the error signal (not forgetting that the ICMP message may come asynchronously from another host, not necessarily immediately).

      The attached source contains an example of such a program, which is expected to print an error unless something is listening on UDP port 33333.

      Attachments

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

        Activity

          People

            cnn Qt Core & Network
            10110111 Ruslan Kabatsayev
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes