Results 1 to 7 of 7

Thread: Udp send and receive problem

  1. #1
    Join Date
    Jan 2020
    Location
    Turkey
    Posts
    4
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Udp send and receive problem

    Hello friends,

    I have a problem.
    I am using Qt Windows 5.12.6 Mingw 32 and 64 bit. First I send a message to brodcast address 255.255.255.255 using udp protocol. I send this message from other client devices I check and send different packages to the device I started broadcasting in return. I have this problem. The system is working properly when I make the program listening with Wireshark in the background. So I can send and receive packages. However, after I leave the network adapter that I selected in wireshark or when wireshark is off, my program stops sending and receiving packets.

    I gave full authorization to both programs I tested on the firewall. But I couldn't solve this problem. I'm also packing this problem with windeployqt after compiling it as release or debug. Although I authorize this program from the firewall and run it as an administrator, I cannot send or receive any packages. Have you ever experienced a similar error? If there is how it is solved. Thank you very much in advance.

    Happy codings,

  2. #2
    Join Date
    Jun 2012
    Location
    Austria
    Posts
    9
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Udp send and receive problem

    Please give more details about your setup:
    Are both the broadcasting machine (lets call it client) and the machine expected to reply (lets call it server) running your Qt based program? All Windows10 machines?
    On which machine do you run wireshark?
    The firewall you are talking about is the Windows firewall / Defender, right?
    Are you sure that the client machine stops sending the broadcast? Maybe there is some other problem, like blocked "Unicast responses to multicast broadcasts" on the server, see e.g. https://docs.microsoft.com/en-us/win...icastbroadcast

  3. #3
    Join Date
    Jan 2020
    Location
    Turkey
    Posts
    4
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Udp send and receive problem

    Quote Originally Posted by stryga42 View Post
    Please give more details about your setup:
    Are both the broadcasting machine (lets call it client) and the machine expected to reply (lets call it server) running your Qt based program? All Windows10 machines?
    On which machine do you run wireshark?
    The firewall you are talking about is the Windows firewall / Defender, right?
    Are you sure that the client machine stops sending the broadcast? Maybe there is some other problem, like blocked "Unicast responses to multicast broadcasts" on the server, see e.g. https://docs.microsoft.com/en-us/win...icastbroadcast
    Server program and client program are available. The server is throwing a data with a broadcast signature. For example: 25AA4B. After this message, the client programs listen to the broadcast continuously and when this signature arrives, they add their information behind this signature and throw it back to me. When I run Wireshark on the client device, I receive the sent packet. The data exchange is interrupted when Wiresh turns the song off. I mentioned the firewall windows defender yes. I allowed both the port I used and authorized the application. His work in connection with Wireshark makes me think a lot. Thank you

  4. #4
    Join Date
    Jan 2020
    Location
    Turkey
    Posts
    4
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Udp send and receive problem

    Folks,

    The problem still continues. Does anyone have an idea ? I wonder if when I run a program running over wireshark or another ethernet, the reason for the packets to come and go may be related to a library that program uses. For example, could wireshark include sys / socket.h and start listening to that controller? I'm going crazy.

  5. #5
    Join Date
    Jul 2008
    Posts
    424
    Thanks
    9
    Thanked 54 Times in 52 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Udp send and receive problem

    Hi, have you tried to temporarily disable the firewall completely?

    Ginsengelf

  6. #6
    Join Date
    Jan 2020
    Location
    Turkey
    Posts
    4
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Udp send and receive problem

    Quote Originally Posted by Ginsengelf View Post
    Hi, have you tried to temporarily disable the firewall completely?

    Ginsengelf
    Yes. I tried firewall. Still failing.

    I think I solved the problem. I flushed the pointer after writing or reading the datagram to the socket object I created. Then I noticed that the error was resolved. I wonder why?

    Qt Code:
    1. .
    2. ..
    3. ...
    4. socket = new QUdpSocket(this);
    5.  
    6. socket->writeDatagram(......);
    7. socket->flush(); < fix it
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,592
    Thanks
    13
    Thanked 1,587 Times in 1,516 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Udp send and receive problem

    Without being able to see your code we can only guess. My guess is that your code does not return to the Qt event loop. To quote the docs, "In most cases, you do not need to call this function, because QAbstractSocket will start sending data automatically once control goes back to the event loop."

Similar Threads

  1. How to send and receive data with Eluetooth Low Energy?
    By tanthinh1510 in forum Qt Programming
    Replies: 0
    Last Post: 5th April 2016, 03:10
  2. QUdpSocket - Send and receive data
    By TheMasterNico in forum Qt Programming
    Replies: 13
    Last Post: 23rd April 2015, 22:24
  3. QUdpsocket send and receive broadcast in linux
    By danics in forum Qt Programming
    Replies: 5
    Last Post: 4th February 2015, 11:26
  4. Replies: 6
    Last Post: 5th February 2011, 20:18
  5. How to send and receive Email ??
    By wincry in forum Newbie
    Replies: 4
    Last Post: 18th October 2009, 17:51

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.