Unsolved Can not send udp packet using writeDatagram
-
Hi,
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:
https://drive.google.com/open?id=0Bychq2mXjGSOMVAzOVJVZERtdmccan anyone download this program and try to run it using QT ceator,and then help me figure out the issue.
Thanks ahead.
-
@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::LocalHost
withQHostAddress::AnyIPv4
when 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?
-
I got:
1 86 Message from: "75.102.43.54" Message port: 12345 Message: "id=1&status=ok&config=mode=decoder,buffer=800,out_gain=+3,dn_relay1=1,ref_id=1078,ref_ip=75.102.43.54,audio_port=55000,time_stamp=1477364862"
My environment:
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
Cheers.
-
@Paul-Colby my god,thanks very much,Paul.I have stuck here for 4 days.You saved me.