[Interest] QUdpSocket

Igor Mironchik igor.mironchik at gmail.com
Wed Feb 28 14:16:00 CET 2018


Hi,

On 28.02.2018 15:49, Konrad Rosenbaum wrote:
> First off: UDP sockets are not connected - it is a connectionless protocol
> in which every data packet is routed on its own.

Sure, I know it, thanks.

>
> Your above code means that the socket will listen on somePort of every
> open interface and may share this with other programs listening on the
> same port.
>
> I hope you are checking the return code of bind! If this is false then the
> socket is left in an undefined state. In this state you will not receive
> any data (or be able to send anything) - you may or may not get errors
> when you try.

Sure, I check codes. My IPC works. I just want to know should I care 
about something with UDP or I can just do bind() and process pending 
datagrams, and don't worry about something additional in my code?! Thanks.

>
> If somePort is 0 then the OS will chose a port for you. The assignment is
> somewhat unpredictable.
>
> If somePort is <=1024 then the OS may block your bind attempt, because the
> port is privileged.
>
> If somePort is used exclusively by another program or the OS, then bind
> will also fail.
>
> SomePort may be blocked in your firewall. Or you may simply be mistaken
> about the port number. You can check those cases with Wireshark.
>
> The network interface on which you are hoping to receive data may be down.
> You can check this with ipconfig (Windows) or ifconfig (Linux/Unix/Mac).
>
> Your sending process might be sending to the wrong target address - it
> needs to send to either one of your interface addresses or a multicast
> group that your socket has joined.
>
> If your sending process has bound its socket then the address must be
> compatible with the target address (e.g. it is impossible to send from
> 127.0.0.1 to 192.168.1.2 or from a multicast address). You can check
> bindings with netstat, you can check whether packets are sent with
> Wireshark.
>
> Your sending process and your receiving process might use different
> protocols (IPv4 vs. IPv6) if you messed up some settings. You can find out
> with netstat and Wireshark.
>
> Good luck with your diagnosis!
>
> Konrad
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest




More information about the Interest mailing list