Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAbstractSocket::connectToHost(), receive broadcast UDPdatagrams?
Qt 6.11 is out! See what's new in the release blog

QAbstractSocket::connectToHost(), receive broadcast UDPdatagrams?

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 378 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • mastupristiM Offline
    mastupristiM Offline
    mastupristi
    wrote on last edited by A Former User
    #1

    Can I use QAbstractSocket::connectToHost() to receive broadcast udp datagrams?

    If I try the unmodified broadcastsender/receiver all works and netstat is:

    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    udp6       0      0 :::52337                :::*                                12185/./broadcastse 
    udp6       0      0 :::45454                :::*                                12172/broadcastrece
    

    I modified broadcastreceiver as follow:

    //! [0]
        udpSocket = new QUdpSocket(this);
        udpSocket->bind(45454, QUdpSocket::ShareAddress);
        udpSocket->connectToHost(QHostAddress(QHostAddress::Any),0); // <- added line
    //! [0]
    

    Now it does not receive broadcast datagrams, but it receive correctly unicast datagrams.

    the netstat command report is:

    Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
    udp6       0      0 ::1:45454               ::1:*                   ESTABLISHED 11488/broadcastrece
    

    I wonder why it seems different local address, and where am I wrong.

    best regards
    Max

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved