How are Pwn Challenges servers set up?

I am curious about the servers used in the Pwn Challenges. How are they set up o that when a connection is received to a particular port, the executable of the challenge is served.

I have been researching around and landed in something involving a service attached to a socket listening to the port, but I don’s understand how the stdout and stdin is then redirected to the client.

Thank you for any insight.