PDA

View Full Version : Udp send and receive problem



ruzgarin_oglu
15th January 2020, 18:44
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,

stryga42
17th January 2020, 05:02
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/windows/client-management/mdm/firewall-csp#disableunicastresponsestomulticastbroadcast

ruzgarin_oglu
17th January 2020, 08:06
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/windows/client-management/mdm/firewall-csp#disableunicastresponsestomulticastbroadcast

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

ruzgarin_oglu
21st January 2020, 15:38
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.

Ginsengelf
22nd January 2020, 08:33
Hi, have you tried to temporarily disable the firewall completely?

Ginsengelf

ruzgarin_oglu
23rd January 2020, 21:56
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?



.
..
...
socket = new QUdpSocket(this);

socket->writeDatagram(......);
socket->flush(); < fix it

ChrisW67
25th January 2020, 08:34
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."