QTcpServer multiple clients without threads
Solved
General and Desktop
-
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 aQSignalMapper
,so when comes the data ,thereadyread
function how to get which client send this data ? And how to property handle one clinet disconnected (As for the Qlist remove control )? -
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.
-
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.