How QT handle the concurrency network request?



  • the requirement :

    one sever as matser node ,many client as slave node .

    slave nodes collect some real-time information of themselves ,once the network set ready .slave node push the information to matser node on their own periodically(for example :node 1 period is 10 seconds ,node 2 is another value) .

    My question:

    1. can I use the udpsocket to achieve this goal ?
    2. if use tcpsocket,should I need mutil-thread to handle this problem ?assume there is 100 node ,that is to say i need use 100 thread ?
      3.every connection need a timer to control it ?

    so what are usual ways that experienced developers to handle this situation ? or maybe i should use some other third library as boost asio ?I have heard the method NIO channel in JAVA, so i want to find the same method in QT,does it exist ?



  • If you can live with the flaws of UDP (losing some data every once in a while) then you can use it otherwise threads on the server, 1 for each client is the way to go



  • but i don;t think 100 threads in one process is a good ideal



  • It's not like having 100 working threads crunching numbers and fighting for CPU time, most of them will be idle unless there is data to be transmitted. The firefox instance I'm using to type this message, for example, is running 100 threads


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.