Creating a (threaded) game server in C ++ / WinSock

I have a game I'm working on in C ++ and OpenGL. I created a stream server, which now receives clients (the game) and receives messages from them. Now the game only sends messages. I want both the game and the server to be able to send and receive, but I'm not sure if this is the best way. I considered using a stream for sending and one for receiving, as in the same socket. Now the game works in one thread, and the server creates a separate thread for each client.

Look for suggestions on how to do this for the game, as well as for the server (if your offer is not the same for both). Any questions, feel free to ask :)

Thank!

+3
source share
3

, . , 2 , , A, - B. A WaitOnMultipleObjects() /mutex/condition . , - , . , B, B.

. , - , .

+1

. AAA - , - , .

+1

Consider using Boost.ASIO, which implements this well with the C ++ API (allows many different approaches besides asynchronous I / O). There are many textbooks . However, for absolute maximum performance, you probably shouldn't use threads.

0
source

Source: https://habr.com/ru/post/1734180/


All Articles