Dear visitor, welcome to QtForum.org.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.

Server using QUdpSocket

Hi,

i'm creating an udp server in my game using udp comunication. I woudl like to know if my approach is correct. Becouse of connectionless character of udp I use one thread that wait for new datagram and send it to working thread:

this way your thread will always be looping around and around. The bind method would let the thread be idle.

If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

why would you choose a method that doesn't want to share CPU vs one that would?

If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

why would you choose a method that doesn't want to share CPU vs one that would?

If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Source code

The above code with no allowance for sleeping/switching is not 'nice' code - It does not want to give up any cpu time. Just because you make threads, doesn't mean that each thread will 'play nice'.

If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.