Important: Please read the Qt Code of Conduct -

QUdpSocket::writeDatagram and connected UDP sockets

  • Hi there again,

    The documentation for "QUdpSocket::writeDatagram": says:

    bq. Warning: Calling this function on a connected UDP socket may result in an error and no packet being sent. If you are using a connected socket, use write() to send datagrams.

    but provides no reason or explanation of why and when it results in error.

    Actually I am successfully using writeDatagram with both unconnected and "connected" QUdpSockets (via connectToHost()) on my Qt Windows application that is going to be compiled for other platforms too. And I can't see why this can fail.

    The source code of QNativeSocketEnginePrivate::nativeSendDatagram which does the actual datagram sending also looks very innocent, only able to generate DatagramTooLargeError and the generic NetworkError errors.

    I'm looking for more insight about this, probably from developers themselves. :)

Log in to reply