Details
-
Suggestion
-
Resolution: Unresolved
-
P4: Low
-
None
-
5.13
-
None
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.