An example of a multithreaded TCP IP server

I would like an example of C ++ code for Windows 10, using Visual C ++ 2019 Community, where a TCP IP server accepts connections from many clients simultaneously. I guess you have to use threads. I need this example for study. One use of it could be that in which clients have to connect to a database by sending a query. Could you help me ?
Thank you in advance for your kind attention.
I realize I'm about to link to Berkley-style socket functions that are popular on Linux, but I bet you could find the corresponding Windows WinSock functions behave similarly. When calling listen, the important parameter is backlog for increasing the number of simultaneous connections that you are willing to accept simultaneously. During handling each accept'ed connection, you would want the program to do this as quickly as possible (because there can only be #backlog accepts running at the same time). To handle quickly you could spawn off new threads or have a thread pool that is doing the work. That architecture is up to you.

https://linux.die.net/man/2/listen
https://linux.die.net/man/2/accept

https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-listen
https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-accept
Topic archived. No new replies allowed.