I made an online connect 4 game that uses the following logic:

Player1 sends their move to the server

Server sends the move to Player2

Player2 receives the move, makes their own move and sends it to the server

Server sends the move to Player1

Player1 receives the move, makes their own move and sends it to the server

(until someone wins or it's a draw)


It works but there is a problem: when player1 takes a while to choose their move and player2 is waiting to receive, player2's pygame window becomes unresponsive since it is stuck in a .recv() call. How can I fix this?
You need to use threading and events. This way, the pygame window can refresh while another thread waits for any updates from the server.
As soon as the thread receives the update, an event should handle it to the main thread.
I don't remember much about implementation details (i'm a C# developer), but i used this while waiting for a AI to complete in Python.
pygame window Not responding error (using sockets)