Pinging other servers to check if they are online with C++

Easiest is probably to write a separate proxy program that listens to the appropriate ports for UDP or TCP (as desired.)

When it receives an incoming connection, it spins up the appropriate server process if it’s not already running, and forwards incoming/outgoing traffic between the server and the outside world, working in effect as a reverse NAT proxy. (The server can then bind to other ports, that you don’t expose to the outer world.)