Can not send udp packet using writeDatagram
I have a small udp sending and receiving program to test the communcation with remote server.
after I ran it in qt ceator,I can not get the response from server ,and I can not capture the packet sent by client using wireshark even though the bind and writeDatagram function works fine.
here is the code:
can anyone download this program and try to run it using QT ceator,and then help me figure out the issue.
@Jeffson I tested: writeDatagram does not work: it returns -1 and error() returns QAbstractSocket::NetworkError
Just at a glance, I think you might need to replace
QHostAddress::AnyIPv4when you bind the socket?
edit: Yep, just made that one change and it worked for me. Cheers :)
@Paul-Colby wow,you can get the server reply?what is your environment?
1 86 Message from: "18.104.22.168" Message port: 12345 Message: "id=1&status=ok&config=mode=decoder,buffer=800,out_gain=+3,dn_relay1=1,ref_id=1078,ref_ip=22.214.171.124,audio_port=55000,time_stamp=1477364862"
Linux paul-XPS-13-9343 4.8.0-26-generic #28-Ubuntu SMP Tue Oct 18 14:39:52 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux QMake version 3.0 Using Qt version 5.6.1 in /usr/lib/x86_64-linux-gnu
@Paul-Colby my god,thanks very much,Paul.I have stuck here for 4 days.You saved me.