[Qt-interest] QUdpSocket's writeDatagram source port

Konrad Rosenbaum konrad at silmor.de
Wed Oct 28 16:26:21 CET 2009


On Wednesday 28 October 2009 13:09:30 Valentin Iliu wrote:
> But calling bind() with no arguments is actually calling bind(0), which
> means "listen to any port"?!  If so, that's not acceptable for me, because
> I want the callback function to deal with only the other side's response,
> not with any message coming to my app via UDP...

No bind(0) means that your OS will chose a port for you. After bind you can 
ask the socket for the one you were given.

Rule of thumb: if you write a client bind to "port 0", so you get any free 
port. If you write a server bind to a specific one (>1024 to be portable), so 
clients can find you.

You still have to filter incoming messages for the ones you are interested 
in - UDP is not connected, so anyone can send you messages to your (randomly) 
assigned port.


	Konrad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091028/6c618e33/attachment.bin 


More information about the Qt-interest-old mailing list