Python sockets accepting multiple connections from different IPs simultaneously to run a remote CTF challenge

Viewed 23

I am trying to create a simple Capture the Flag challenge for an event. The actual task is simple: my remote "server" (an Amazon EC2 instance) with a listening socket(?) will be running some code that asks users to play rock, paper, scissors with the computer, and the user will have to beat 3 rounds before getting the flag. I expect to write the code in Python, and I expect users to connect either manually via netcat or with code that will brute-force the winning combination.

The concern is that I will have max of 150 people trying to connect at the same time to the same IP and port (but coming from different client IPs and ports) and, whenever a new person connects, I need the server code to start up a new game without interrupting or closing the games/connections from the other users already playing.

I tested out my simple program and confirmed that the listener will only take one connection at a time; however, I tried some multithreaded socket server code from various blog posts online and those seem to close the first connection as soon as I establish a second connection. What am I missing here? What do I need? I'm assuming socketserver for python3, and probably multithreading, but what else? Is there a simpler approach? Would creating my code as a service help? What about using a proxy?

0 Answers
Related