I'm having a bit of trouble learning how to multithread a socket server.
I have everything working perfectly fine, but it only accepts one client (I would like multiple clients).
I would appreciate some sort of example, please!
(Sorry if that's too much, I have troubles understanding some things, unless its visual).
For a recent assignment, I created a multithreaded TCP server.
When the NetworkManager was created, it created a listener thread, which kept listening for clients. When a new client was found, a new thread spun off for that client.
I understand enough to say that,
But i don't understand enough to code it.
As in, I have no idea how to even start a multithread.
I tried, and failed.
If I created a thread, what would I put in it? All of the socket information?
How can I tell if a client has connected and start another socket once accepted?
Do I remove socket info from the main function and replace it into the multithreaded function? Or do I keep it there, too?