QTcpServer multiple clients without threads



  • I want to write a sever that can handle multiple clients and without using threads . I have already read some website about this topic . The main way is use a QList(or other STL)and a QSignalMapper,so when comes the data ,the readyread function how to get which client send this data ? And how to property handle one clinet disconnected (As for the Qlist remove control )?


  • Lifetime Qt Champion

    Hi,

    On way is to used the sender method in your slot. You can take the Fortune Server Example as a starting point and rather than closing the connection at the end of the function, store it in your container.


  • Qt Champions 2016

    Look at this as well. It's a threaded TCP server, but you can remove the QThread related code in the server object and you'd be good to go.


Log in to reply
 

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