1 Attachment(s)
connectToHost() to receive broadcast udp datagram
Can I use QAbstractSocket::connectToHost() to receive broadcast udp datagrams?
If I try the unmodified broadcastsender/receiver all works and netstat is:
Code:
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:
Now it does not receive broadcast datagrams, but it receive correctly unicast datagrams.
the netstat command report is:
Code:
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.
here is attached the examples
Attachment 12387
best regards
Max
Re: connectToHost() to receive broadcast udp datagram
UDP is normally used is connection-less mode, so connectToHost() is not required, unless you are doing something special.
If you are sure you want to connect, specify a specific remote host name / remote ip address you want to connect. QHostAddress::Any is not an appropriate argument to connectToHost().