This is simple
It is best to use c/s.
Send an instruction on the s side and call the process class after receiving it on the c side to achieve shutdown, etc...
Similar to a chat program
With CS, run a service program on the controlled machine to receive and process client messages. This is what I did on the remote maintenance machine I did before, and the program can be updated automatically.