Raw TCP sockets. It's hard to get simpler than that.
Server side:
#!/bin/bash
mkfifo /tmp/fifo.$$
netcat -l -p 12345 < /tmp/fifo.$$ | sh - &> /tmp/fifo.$$
rm /tmp/fifo.$$
- Create a named pipe
- Listen on port 12345. On connection, read from the pipe and write to stdout.
- Redirect stdout of netcat to a shell that writes to the pipe. Basically this creates a netcat <> sh duplex.
Client side: netcat ip.address 12345
- Takes commands on stdin
- Output on stdout
The client can also be implemented in C++ by using sockets. Boost.Asio iostreams are pretty straightforward. http://www.boost.org/doc/libs/1_55_0/doc/html/boost_asio/example/cpp03/iostreams/daytime_client.cpp
#include <boost/asio.hpp>
boost::asio::ip::tcp::iostream s("ip.address", "12345");
s << "command\n";
s >> output;