I have written a TCP server with Win32 API and C++ but it's single-threaded. Can anyone tell me how would I go about making it multi-threaded? I imagine for every new accepted connection, I'd have to spawn a thread that takes care of it. But I have never had experience with threading in Win32. Can anyone tell me how I would go about threaded programming with Win32 and C++?
Asked
Active
Viewed 2.3k times
8
-
3Call `CreateThread()`. This question is too general. – David Heffernan Aug 31 '11 at 16:32
-
Note that one-thread-per-socket setups are almost never the right design. I suggest you look into a setup with a fixed number of threads either using non-blocking sockets or [I/O completion ports](http://msdn.microsoft.com/en-us/library/aa365198(v=vs.85).aspx). – André Caron Aug 31 '11 at 16:38
-
Note: eventually, you can use boost::thread library. – neodelphi Aug 31 '11 at 16:44