I have actually done this to remotely "Press the on button" on another computer to turn it on by wiring up a relay to be controlled by a Pi via a GPIO pin. However you probably don't use RISCOS so the code is not very useful but the concept might be. I wrote, some time ago (1997 approx), a inetd equivalent and used this to listen on a UDP port waiting for a message over the net. The inetd then runs my program, one I wrote last year, to modify the state of a pin or pins according to the information in the UDP packet. That's the server end. The client end could go two ways. The first is you could send the UDP packet directly from the client, the second, by using a website, on another machine, from the client which in turn sends the UDP packet, I chose a server running Glassfish as I could write this bit in Java. If running Linux on the Pi then the inetd and Glassfish could run on the same Pi, but you would have to use a Pi 3 as the Glassfish is very resource hungry.
An alternative, you could write the server end in Java running on Glassfish or Tomcat and use the Pi4J library to communicate with the GPIO, this misses out the inetd part and all you have to do on your client is go to a web page.
There were reasons I went down the longer and convoluted route to fit in my situation, the alternative above may be better for you.